Decode the decimal sum:
T H I S
+ I S A
+ G R E A T
+ T I M E
-----------
W A S T E R
Same letter, same digit; different letters, different digits.
5628
280
97405
5234
------
108547
FOR t = 1 TO 9
IF used(t) = 0 THEN
used(t) = 1
FOR i = 1 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR g = 1 TO 9
IF used(g) = 0 THEN
used(g) = 1
FOR w = 1 TO 9
IF used(w) = 0 THEN
used(w) = 1
FOR h = 0 TO 9
IF used(h) = 0 THEN
used(h) = 1
FOR s = 0 TO 9
IF used(s) = 0 THEN
used(s) = 1
FOR a = 0 TO 9
IF used(a) = 0 THEN
used(a) = 1
FOR r = 0 TO 9
IF used(r) = 0 THEN
used(r) = 1
FOR e = 0 TO 9
IF used(e) = 0 THEN
used(e) = 1
FOR m = 0 TO 9
IF used(m) = 0 THEN
used(m) = 1
this = t * 1000 + h * 100 + i * 10 + s
isa = i * 100 + s * 10 + a
great = g * 10000 + r * 1000 + e * 100 + a * 10 + t
time = t * 1000 + i * 100 + m * 10 + e
waster = w * 100000 + a * 10000 + s * 1000 + t * 100 + e * 10 + r
IF this + isa + great + time = waster THEN
PRINT USING "######"; this
PRINT USING "######"; isa
PRINT USING "######"; great
PRINT USING "######"; time
PRINT USING "######"; waster
END IF
used(m) = 0
END IF
NEXT
used(e) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
used(s) = 0
END IF
NEXT
used(h) = 0
END IF
NEXT
used(w) = 0
END IF
NEXT
used(g) = 0
END IF
NEXT
used(i) = 0
END IF
NEXT
used(t) = 0
END IF
NEXT
|
Posted by Charlie
on 2008-12-29 19:04:52 |