Project Euler #38: Pandigital multiples

  • + 0 comments

    python 3

    def result():

    a = list(map(int,input().split()))
    n,k = a[0],a[1]
    s = [i+1 for i in range(k)]
    ans = []
    for i in range(2,n+1):
        temp = ""
        j = 1
        while len(temp)<=k :
            if len(temp) == k:
                temp = sorted([int(k) for k in temp])
                if temp == s :
                    ans.append(i)
                    break
            num = i*j
            temp += str(num)
            j += 1
    ans.sort()
    return ans