Substitute each of the capital letters in bold by a different digit from 0 to 9 such that the sum of digits of each of POIRE, OPERA, PORTE, TAPIS, ASTRE, PATRE, LOTUS, LISTE, LOUPE and, OUTRE (in this order) constitutes ten consecutive terms of an arithmetic sequence in ascending order. It is known that none of P, O, T, A and L can be zero.
DIM used(-100 TO 100)
FOR k = 0 TO 9
FOR a = 1 TO 9
used(a) = 1
i = a - k
IF used(i) = 0 AND i >= 0 AND i < 10 THEN
used(i) = 1
t = a + k
IF used(t) = 0 AND t > 0 AND t < 10 THEN
used(t) = 1
FOR p = 1 TO 9
IF used(p) = 0 THEN
used(p) = 1
s = p - k
IF used(s) = 0 AND s >= 0 AND s < 10 THEN
used(s) = 1
FOR r = 0 TO 9
IF used(r) = 0 THEN
used(r) = 1
e = p + a - r
IF used(e) = 0 AND e >= 0 AND e < 10 THEN
used(e) = 1
IF p + e = t + s + 2 * k THEN
l = t + r - p - k
IF used(l) = 0 AND l > 0 AND l < 10 THEN
used(l) = 1
o = 2 * i + s - r - e
IF used(o) = 0 AND o > 0 AND o < 10 THEN
used(o) = 1
u = i + e - o - k
IF used(u) = 0 AND u >= 0 AND u < 10 THEN
used(u) = 1
GOSUB printIt
used(u) = 0
END IF
used(o) = 0
END IF
used(l) = 0
END IF
END IF
used(e) = 0
END IF
used(r) = 0
END IF
NEXT r
used(s) = 0
END IF
used(p) = 0
END IF
NEXT p
used(t) = 0
END IF
used(i) = 0
END IF
used(a) = 0
NEXT a
NEXT k
END
printIt:
PRINT "poire", p; o; i; r; e, p + o + i + r + e
PRINT "opera", o; p; e; r; a, o + p + e + r + a
PRINT "porte", p; o; r; t; e, p + o + r + t + e
PRINT "tapis", t; a; p; i; s, t + a + p + i + s
PRINT "astre", a; s; t; r; e, a + s + t + r + e
PRINT "patre", p; a; t; r; e, p + a + t + r + e
PRINT "lotus", l; o; t; u; s, l + o + t + u + s
PRINT "liste", l; i; s; t; e, l + i + s + t + e
PRINT "loupe", l; o; u; p; e, l + o + u + p + e
PRINT "outre", o; u; t; r; e, o + u + t + r + e
RETURN
finds
word digits s.o.d.
poire 2 3 5 0 8 18
opera 3 2 8 0 6 19
porte 2 3 0 7 8 20
tapis 7 6 2 5 1 21
astre 6 1 7 0 8 22
patre 2 6 7 0 8 23
lotus 4 3 7 9 1 24
liste 4 5 1 7 8 25
loupe 4 3 9 2 8 26
outre 3 9 7 0 8 27
|
Posted by Charlie
on 2009-11-21 15:13:53 |