Category Archives: Stuff - Page 3

Quotes: Michael Feldman

“Java is, in many ways, C++-.”

(Michael Feld­man)

Euler’s Problem: 20

n! means n * (n-1) * … * 3 * 2 * 1

Find the sum of the dig­its in the num­ber 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>

Euler’s Problem: 112

Work­ing from left-to-right if no digit is exceeded by the digit to its left it is called an increas­ing num­ber; for exam­ple, 134468.

Sim­i­larly if no digit is exceeded by the digit to its right it is called a decreas­ing num­ber; for exam­ple, 66420.

We shall call a pos­i­tive inte­ger that is nei­ther increas­ing nor decreas­ing a “bouncy” num­ber; for exam­ple, 155349.

Clearly there can­not be any bouncy num­bers below one-hundred, but just over half of the num­bers below one-thousand (525) are bouncy. In fact, the least num­ber for which the pro­por­tion of bouncy num­bers first reaches 50% is 538.

Sur­pris­ingly, bouncy num­bers become more and more com­mon and by the time we reach 21780 the pro­por­tion of bouncy num­bers is equal to 90%.

Find the least num­ber for which the pro­por­tion of bouncy num­bers 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>

Code Review with Review Board

Review Board is a pow­er­ful web-based code review tool that offers devel­op­ers an easy way to han­dle code reviews. It scales well from small projects to large com­pa­nies and offers a vari­ety 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 qual­ity tools avail­able, leav­ing devel­op­ers 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 com­pa­nies. In both cases, code reviews were typ­i­cally done over e-mail. A sig­nif­i­cant amount of time was spent in form­ing review requests, switch­ing between the diff and the e-mail, and try­ing to under­stand what parts of the code the reviewer was refer­ring to.

So in an effort to keep our san­ity and improve the process both in our open source projects and at com­pa­nies, we wrote Review Board. We hope it will be use­ful to your team too so you can focus on what’s impor­tant: writ­ing great products.

http://www.reviewboard.org

Biolab Disaster, HTML5 and JS

This nice plat­form game was built with just html5/canvas and javascript!

http://www.phoboslab.org/biolab/

Applying transformations to your bugs

Great arti­cle by MoR­pHeUz (a.k.a. Artur Souza) about Apple doing “dummy” job.

http://blog.morpheuz.cc/16/07/2010/applying-transformations-to-your-bugs/

Definition: fag

  1. An extremely annoy­ing, incon­sid­er­ate per­son most com­monly asso­ci­ated with Harley riders.
  2. A per­son who owns or fre­quently rides a Harley.

    wallpaper: FreeBSD red

    Screenshot: to mornok

    wallpaper: RAGE