Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import combinations_with_replacement
- from time import clock
- t0 = clock()
- numbers = "0123456789"
- for n in xrange(1, 40):
- print "n=", n, clock() - t0
- if n in [2,12,13,15,18,22,26,28,30,36]: continue
- pows = dict(zip(numbers, [i ** n for i in range(10)]))
- mini, maxi = 10 ** (n-1), 10 ** n
- for digits in combinations_with_replacement(numbers, n):
- sumpows = sum([pows[d] for d in digits])
- if mini <= sumpows < maxi and tuple(sorted(str(sumpows))) == digits:
- print sumpows, clock() - t0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement