“Java is, in many ways, C++-.”
(Michael Feldman)
n! means n * (n-1) * … * 3 * 2 * 1
Find the sum of the digits in the number 100!
#!/usr/bin/env python
t = 1
x = 0
for i in range(1,101):
t = t * i
for i in str(t):
x = x + int(i)
print x
/home/umgeher/war/hg/euler/python> time python 20.py 648 Time spent in user mode (CPU seconds) : 0.016s Time spent in kernel mode (CPU seconds) : 0.008s Total time : 0:00.02s CPU utilisation (percentage) : 50.0% Times the process was swapped : 0 Times of major page faults : 0 Times of minor page faults : 649 /home/umgeher/war/hg/euler/python>
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420.
We shall call a positive integer that is neither increasing nor decreasing a “bouncy” number; for example, 155349.
Clearly there cannot be any bouncy numbers below one-hundred, but just over half of the numbers below one-thousand (525) are bouncy. In fact, the least number for which the proportion of bouncy numbers first reaches 50% is 538.
Surprisingly, bouncy numbers become more and more common and by the time we reach 21780 the proportion of bouncy numbers is equal to 90%.
Find the least number for which the proportion of bouncy numbers is exactly 99%.
#!/usr/bin/env python
def calc(x):
a = d = False
x = str(x)
for y in range(len(x)-1):
if x[y+1] > x[y]:
a = True
elif x[y+1] < x[y]:
d = True
if a and d:
return True
return False
x = 21780
p = 0.90
b = x * p
while p != 0.99:
x+= 1
if calc(x):
b+= 1
p = float(b)/x
print x
/home/umgeher/war/hg/euler/python> time python 112.py 1587000 Time spent in user mode (CPU seconds) : 5.449s Time spent in kernel mode (CPU seconds) : 0.007s Total time : 0:05.46s CPU utilisation (percentage) : 99.6% Times the process was swapped : 0 Times of major page faults : 0 Times of minor page faults : 649 /home/umgeher/war/hg/euler/python>
Review Board is a powerful web-based code review tool that offers developers an easy way to handle code reviews. It scales well from small projects to large companies and offers a variety of tools to take much of the stress and time out of the code review process.
For too long, code reviews have been too much of a chore. This is largely due to the lack of quality tools available, leaving developers to resort to e-mail and bug tracker-based solutions.
We’ve seen a lot of time and energy wasted doing code reviews both in open source projects and at companies. In both cases, code reviews were typically done over e-mail. A significant amount of time was spent in forming review requests, switching between the diff and the e-mail, and trying to understand what parts of the code the reviewer was referring to.
So in an effort to keep our sanity and improve the process both in our open source projects and at companies, we wrote Review Board. We hope it will be useful to your team too so you can focus on what’s important: writing great products.
Great article by MoRpHeUz (a.k.a. Artur Souza) about Apple doing “dummy” job.
http://blog.morpheuz.cc/16/07/2010/applying-transformations-to-your-bugs/