Problem 62 Cubic permutations

2019-07-12 08:30:00   技术   python projecteulor

The cube, 41063625 ( \(345^3\) ), can be permuted to produce two other cubes: 56623104 ( \(384^3\) ) and 66430125 ( \(405^3\) ). 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.

这个感觉很简单啊

LIST = {}
for i in range(1, 10000):
    result = i*i*i
    LIST[i] = result


LL = {}

for key in LIST:
    n = list(str(LIST[key]))
    n.sort()
    nnn = ''.join(n)
    if LL.has_key(nnn):
        LL[nnn].append(LIST[key])
    else:
        LL[nnn] = [LIST[key]]

print len(LL)
for key in LL:
    if len(LL[key]) == 5:
        print LL[key]
评论共