# Project Euler #62: Cubic permutations

# Project Euler #62: Cubic permutations

+ 1 comment Hi, How can there be several sets of numbers if we are asked to print the smallest cube with the property? How can there be several smallest numbers?

Thanks

+ 0 comments **Hint:**Try to use hash/dictionary to store data, then you can save a lot of running time!For example: {'01234566': [41063625, 56623104, 66430125]} within:

41063625 = 345^3; 56623104 = 384^3; 66430125 = 405^3

'01234566' is a sorted string that contains all digits

+ 0 comments If you're failing tests 0, 3, 5 but passing all others it's probably because you included entries larger than n in your permutations. For example, {1, 2, 3} is k=3, but for n = 2, k for the list is only 1 as both 2 and 3 are larger or equals to n.

+ 1 comment Hi, can anyone please give more testcases with max valus of N and K? I am failing test-cases from #5 to #9.

+ 1 comment please suggest improvements.....can only pass 0 and 1st cases

i=0; cubes=[] n,k=map(int,input().split(' ',1)) while(1): cube=sorted(list(str(i**3))) cubes.append(cube) if(cubes.count(cube)==k): print(pow(cubes.index(cube),3)) break i=i+1

Sort 6 Discussions, By:

Please Login in order to post a comment