Project Euler Problem 009

http://projecteuler.net/index.php?section=problems&id=9

A Pythagorean triplet is a set of three natural numbers, a  b  c, for which,

    a^2 + b^2 = c^2

For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

a + b + c = 1000 (0 <= a < b < c) の条件を優先してGreedyに探した。解説は読んだけど分からなかった。

def abc(total=1000):
    for a in xrange(0, total/3):
        aa = a * a
        for b in xrange(a + 1, (total-a+1)/2):
            c = total - a - b
            
            if aa + b * b == c * c:
                print (a, b, c, a * b * c)
                return a * b * c
                
print abc()


答え: 200 * 375 * 425 = 31875000
実行時間: 0.026095秒くらい