The 3-digit cubes are:
125
216
343
512
729
The 4-digit cubes are:
1000
1331
1728
2197
2744
3375
4096
4913
5832
6859
8000
9261
The 5-digit cubes are:
10648
12167
13824
15625
17576
19683
21952
24389
27000
29791
32768
35937
39304
42875
46656
50653
54872
59319
64000
68921
74088
79507
85184
91125
97336
The following program tries all the ways of fitting these into the diagram, and checks if each solution uses all but one of the ten possible digits:
DEFDBL A-Z
CLS
DIM dig3$(5), dig4$(12), dig5$(25)
FOR i = 1 TO 46
i3 = i * i * i
SELECT CASE i3
CASE 100 TO 999
no3s = no3s + 1
dig3$(no3s) = LTRIM$(STR$(i3))
CASE 1000 TO 9999
no4s = no4s + 1
dig4$(no4s) = LTRIM$(STR$(i3))
CASE 10000 TO 99999
no5s = no5s + 1
dig5$(no5s) = LTRIM$(STR$(i3))
END SELECT
NEXT
FOR first4 = 1 TO no4s
tf4$ = dig4$(first4)
FOR the5 = 1 TO no5s
t5$ = dig5$(the5)
IF LEFT$(t5$, 1) = RIGHT$(tf4$, 1) THEN
FOR the3 = 1 TO no3s
t3$ = dig3$(the3)
IF MID$(t5$, 3, 1) = RIGHT$(t3$, 1) THEN
FOR last4 = 1 TO no4s
tl4$ = dig4$(last4)
IF RIGHT$(t5$, 1) = RIGHT$(tl4$, 1) THEN
s$ = "0123456789"
x$ = tf4$ + tl4$ + t3$ + t5$
FOR i = 1 TO LEN(x$)
ix = INSTR(s$, MID$(x$, i, 1))
IF ix THEN
s$ = LEFT$(s$, ix - 1) + MID$(s$, ix + 1)
END IF
NEXT i
IF LEN(s$) = 1 THEN
PRINT tf4$
PRINT " "; MID$(t5$, 2, 1)
PRINT " "; t3$
PRINT " "; MID$(t5$, 4, 1)
PRINT tl4$, s$
PRINT
ct = ct + 1
END IF
END IF
NEXT last4
END IF
NEXT the3
END IF
NEXT
NEXT
PRINT ct
It produces:
1331
7
125
7
4096 8
3375
0
216
5
4913 8
4096
8
729
2
1331 5
The unused digit is shown to the right. The unique one is for the third solution, which was therefore the solution of the narrator.
Adapted from New Scientist's Enigma number 1353, published in the August 13-19, 2005 issue. |