Different letters represent different numbers and none of them is equal to zero.
NOSIER
+ ASTRAL
725613
What word does the final result represent ?
(In reply to
Solution by e.g.)
I agree there are probably more elegant methods, but even with an inelegant method, a solution is more than just the answer. Here's my solution in the form of a program, which had taken me more time to write than the 8 minutes e.g. took.
DECLARE SUB permute (a$)
CLS
a1$ = "nosier"
a2$ = "astral"
tr$ = "nosieratl"
FOR perm = 1 TO 362880
v1$ = a1$
FOR i = 1 TO LEN(v1$)
MID$(v1$, i, 1) = LTRIM$(STR$(INSTR(tr$, MID$(v1$, i, 1))))
NEXT
v2$ = a2$
FOR i = 1 TO LEN(v2$)
MID$(v2$, i, 1) = LTRIM$(STR$(INSTR(tr$, MID$(v2$, i, 1))))
NEXT
t = VAL(v1$) + VAL(v2$)
IF t = 725613 THEN
PRINT "123456789"
PRINT tr$
s1$ = ""
FOR i = 1 TO LEN("725613")
s1$ = s1$ + MID$(tr$, VAL(MID$("725613", i, 1)), 1)
NEXT
PRINT s1$
PRINT
END IF
permute tr$
NEXT
SUB permute (a$)
DEFINT A-Z
x$ = ""
FOR i = LEN(a$) TO 1 STEP -1
l$ = x$
x$ = MID$(a$, i, 1)
IF x$ < l$ THEN EXIT FOR
NEXT
IF i = 0 THEN
FOR j = 1 TO LEN(a$) \ 2
x$ = MID$(a$, j, 1)
MID$(a$, j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
MID$(a$, LEN(a$) - j + 1, 1) = x$
NEXT
ELSE
FOR j = LEN(a$) TO i + 1 STEP -1
IF MID$(a$, j, 1) > x$ THEN EXIT FOR
NEXT
MID$(a$, i, 1) = MID$(a$, j, 1)
MID$(a$, j, 1) = x$
FOR j = 1 TO (LEN(a$) - i) \ 2
x$ = MID$(a$, i + j, 1)
MID$(a$, i + j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
MID$(a$, LEN(a$) - j + 1, 1) = x$
NEXT
END IF
END SUB
It found
123456789
tnsaleiro
inlets
-----
the first two lines being the full number-to-letter encoding.
Edited on December 28, 2003, 10:16 am
|
Posted by Charlie
on 2003-12-28 10:15:20 |