Find a positive number n such that the digits in n * n and n * n * n are all unique and also include all 10 digits.

In [ ]:
90*90
Out[ ]:
8100
In [ ]:
90*90*90
Out[ ]:
729000
In [ ]:
99*99
Out[ ]:
9801
In [ ]:
99*99*99
Out[ ]:
970299
In [ ]:
100*100
Out[ ]:
10000
In [ ]:
100*100*100
Out[ ]:
1000000

since the answer should be n such that the combined number of digits in n * n and n * n * n should not be more than 10, we see that we can stop checking at 99!

In [ ]:
for n in range(1,100):
    alldigits = []
    n2digits = str(n * n)
    for d in n2digits:
        alldigits.append(int(d))
    n3digits = str(n * n * n)
    for d in n3digits:
        alldigits.append(int(d))
    if len(set(alldigits)) == 10:
        print(n)
69

we can make the program more efficient by starting at a higher number than 1

In [ ]:
40*40
Out[ ]:
1600
In [ ]:
40*40*40
Out[ ]:
64000
In [ ]:
50*50
Out[ ]:
2500
In [ ]:
50*50*50
Out[ ]:
125000
In [ ]:
48*48
Out[ ]:
2304
In [ ]:
48*48*48
Out[ ]:
110592
In [ ]:
47*47
Out[ ]:
2209
In [ ]:
47*47*47
Out[ ]:
103823
In [ ]:
46*46
Out[ ]:
2116
In [ ]:
46*46*46
Out[ ]:
97336
In [ ]:
for n in range(47,100):
    alldigits = []
    n2digits = str(n * n)
    for d in n2digits:
        alldigits.append(int(d))
    n3digits = str(n * n * n)
    for d in n3digits:
        alldigits.append(int(d))
    if len(set(alldigits)) == 10:
        print(n)
69
In [ ]: