Solve probem 125 because I am still farming easy problems.
This commit is contained in:
23
python/e125.py
Normal file
23
python/e125.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from lib_misc import is_palindrome
|
||||||
|
|
||||||
|
|
||||||
|
def euler_125():
|
||||||
|
upper = 10**8
|
||||||
|
ns = set()
|
||||||
|
for i in range(1, upper):
|
||||||
|
i2 = i * i
|
||||||
|
if i2 >= upper:
|
||||||
|
break
|
||||||
|
for j in range(i + 1, upper):
|
||||||
|
i2 += (j * j)
|
||||||
|
if i2 >= upper:
|
||||||
|
break
|
||||||
|
if is_palindrome(i2):
|
||||||
|
ns.add(i2)
|
||||||
|
return sum(ns)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
solution = euler_125()
|
||||||
|
print("e125.py: " + str(solution))
|
||||||
|
assert(solution == 2906969179)
|
||||||
Reference in New Issue
Block a user