Substitute each of the capital letters in this 4x4 grid by a different digit from 0 to 9, such that the sum of each of the four columns as well as the sum of each of the four rows is TO.
S H O P
P I P E
A R E A
R E N T
Note: TO represents the number 10*T + O.
8 7 0 5
5 1 5 9
4 3 9 4
3 9 6 2
20
CLS
FOR t = 0 TO 9
IF used(t) = 0 THEN
used(t) = 1
FOR h = 0 TO 9
IF used(h) = 0 THEN
used(h) = 1
FOR o = 0 TO 9
IF used(o) = 0 THEN
used(o) = 1
tov = 10 * t + o
FOR p = 0 TO 9
IF used(p) = 0 THEN
used(p) = 1
FOR i = 0 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR e = 0 TO 9
IF used(e) = 0 THEN
used(e) = 1
IF p + i + p + e = tov THEN
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 n = 0 TO 9
IF used(n) = 0 THEN
used(n) = 1
FOR s = 0 TO 9
IF used(s) = 0 THEN
used(s) = 1
IF s + h + o + p = tov THEN
IF a + r + e + a = tov THEN
IF r + e + n + t = tov THEN
IF s + p + a + r = tov THEN
IF h + i + r + e = tov THEN
IF o + p + e + n = tov THEN
IF p + e + a + t = tov THEN
PRINT
PRINT s; h; o; p
PRINT p; i; p; e
PRINT a; r; e; a
PRINT r; e; n; t
PRINT tov
END IF
END IF
END IF
END IF
END IF
END IF
END IF
used(s) = 0
END IF
NEXT
used(n) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
END IF' pipe
used(e) = 0
END IF
NEXT
used(i) = 0
END IF
NEXT
used(p) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(h) = 0
END IF
NEXT
used(t) = 0
END IF
NEXT
|
Posted by Charlie
on 2009-10-04 04:22:40 |