euler/python/e062.py

21 lines
515 B
Python
Raw Normal View History

2019-07-18 03:29:59 +02:00
def euler_062():
solutions = {}
for n in range(1, 10000):
cube = n * n * n
try:
key = "".join(sorted(str(cube)))
solutions[key].append(cube)
if len(solutions[key]) > 4:
# print(solutions[key])
s = solutions[key][0]
break
except KeyError:
solutions[key] = [cube]
return s
2019-07-18 03:29:59 +02:00
if __name__ == "__main__":
print("e062.py: " + str(euler_062()))
assert(euler_062() == 127035954683)