From 34980ed0b42b376c6779d6956100d62a638c67cd Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 12 Oct 2020 22:20:47 +0200 Subject: [PATCH] Solve problem --- src/task62 - Cubic permutations.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/task62 - Cubic permutations.py diff --git a/src/task62 - Cubic permutations.py b/src/task62 - Cubic permutations.py new file mode 100644 index 0000000..4dcd2fd --- /dev/null +++ b/src/task62 - Cubic permutations.py @@ -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 \ No newline at end of file