Moved solutions till 35 to Python.

This commit is contained in:
2019-07-16 12:51:07 -04:00
parent f76b36c8d3
commit d94fc90600
13 changed files with 262 additions and 66 deletions

23
python/e032.py Normal file
View File

@@ -0,0 +1,23 @@
from lib_misc import permutations
def is_solution(s):
a, b, c = int(s[0:2]), int(s[2:5]), int(s[5:])
if a * b == c:
return c
a, b, c = int(s[0:1]), int(s[1:5]), int(s[5:])
if a * b == c:
return c
return 0
def euler_032():
return sum(set([is_solution("".join(p))
for p in permutations("123456789")]))
if __name__ == "__main__":
assert(is_solution("391867254") == 7254)
assert(is_solution("391867245") == 0)
print("e032.py: {}".format(euler_032()))
assert(euler_032() == 45228)