Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 809 Bytes

62. Cubic permutations.md

File metadata and controls

23 lines (18 loc) · 809 Bytes

Question

The cube, 41063625 (eq), can be permuted to produce two other cubes: 56623104 (eq) and 66430125 (eq). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.

Find the smallest cube for which exactly five permutations of its digits are cube.

Solution

from collections import defaultdict

def p62():
    d = defaultdict(list)
    for n in range(100, 10000):
        k = ''.join(sorted(str(n ** 3)))
        d[k].append(n)
    return min(v[0] for v in d.values() if len(v) == 5) ** 3

Answer

127035954683