I have taken a liberty to shorten
"The shopkeeper's puzzle" created by H.E. Dudeney about 125 years ago:
If you decode the alphametics gaunt+oiler=rguoei
the sequence 1234567890 will represent a valid English word.
What word?
DECLARE SUB permute (a$)
CLS
a$ = "gauntoiler": h$ = a$
DO
g = INSTR(a$, "g") - 1
a = INSTR(a$, "a") - 1
u = INSTR(a$, "u") - 1
n = INSTR(a$, "n") - 1
t = INSTR(a$, "t") - 1
o = INSTR(a$, "o") - 1
i = INSTR(a$, "i") - 1
l = INSTR(a$, "l") - 1
e = INSTR(a$, "e") - 1
r = INSTR(a$, "r") - 1
gaunt = g * 10000 + a * 1000 + u * 100 + n * 10 + t
oiler = o * 10000 + i * 1000 + l * 100 + e * 10 + r
rguoei = r * 100000 + g * 10000 + u * 1000 + o * 100 + e * 10 + i
IF gaunt + oiler = rguoei THEN
PRINT MID$(a$, 2) + LEFT$(a$, 1)
END IF
permute a$
LOOP UNTIL a$ = h$
finds the possible solutions to the alphametic, for 1234567890, as one of:
reglutiaon
regulation
reugaltion
reutilgaon
rgelutiaon
rgeulation
rguealtion
rgutileaon
rutieglaon
rutigelaon
Only regulation is a valid English word.
Edited on November 20, 2010, 8:32 pm
|
Posted by Charlie
on 2010-11-20 20:31:25 |