Project Euler #62: Cubic permutations

  • + 1 comment

    I don't understand why my code doesn't work?!

    from collections import defaultdict
    d=defaultdict(lambda:[])
    
    n,k=map(int,input().split(' '))
    
    l=[]
    for i in range(1,n):
        temp=i*i*i
        s="".join(sorted(str(temp)))
        d[s].append(i)
        if len(d[s])==k:
            #d[s].sort()
            l.append(pow(min(d[s]),3))
        
    #print(d)
    new=sorted(l)
    for v in new:
        print(v)