Moved problems till e045.py to Python 2.
This commit is contained in:
16
python/e039.py
Normal file
16
python/e039.py
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
def get_triplets_for_perimter(p):
|
||||
return [(a, b, p - a - b)
|
||||
for b in range(1, p // 2 + 1)
|
||||
for a in range(1, b)
|
||||
if a * a + b * b == (p - a - b) * (p - a - b)]
|
||||
|
||||
|
||||
def euler_039():
|
||||
return max([(len(get_triplets_for_perimter(p)), p)
|
||||
for p in range(1, 1001)])[1]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
assert(euler_039() == 840)
|
||||
print("e039.py: " + str(euler_039()))
|
||||
Reference in New Issue
Block a user