Solve problem
This commit is contained in:
18
src/task62 - Cubic permutations.py
Normal file
18
src/task62 - Cubic permutations.py
Normal file
@@ -0,0 +1,18 @@
|
||||
def has5Permutations(n):
|
||||
return numberList[len(n)].count(n) == 5
|
||||
|
||||
numberList = [[] for _ in range(100)]
|
||||
|
||||
i=1
|
||||
while True:
|
||||
|
||||
n = i**3
|
||||
sortedN = ''.join(sorted(str(n)))
|
||||
numberList[len(sortedN)].append(sortedN)
|
||||
|
||||
if has5Permutations(sortedN):
|
||||
index = numberList[len(sortedN)].index(sortedN)
|
||||
print((sum([len(numberList[j]) for j in range(len(sortedN)) ]) + index+1) ** 3)
|
||||
exit(0)
|
||||
|
||||
i += 1
|
Reference in New Issue
Block a user