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.
This does not define the words as well as Charlie has with his but it works.
OPEN "poire.txt" FOR OUTPUT AS #1
CLS
FOR a = 1 TO 9
IF used(a) = 0 THEN
used(a) = 1
FOR o = 1 TO 9
IF used(o) = 0 THEN
used(o) = 1
FOR l = 1 TO 9
IF used(l) = 0 THEN
used(l) = 1
FOR p = 1 TO 9
IF used(p) = 0 THEN
used(p) = 1
FOR t = 1 TO 9
IF used(t) = 0 THEN
used(t) = 1
FOR e = 0 TO 9
IF used(e) = 0 THEN
used(e) = 1
FOR i = 0 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR u = 0 TO 9
IF used(u) = 0 THEN
used(u) = 1
FOR r = 0 TO 9
IF used(r) = 0 THEN
used(r) = 1
FOR s = 0 TO 9
IF used(s) = 0 THEN
used(s) = 1
a1 = p + o + i + r + e
a2 = o + p + e + r + a
a3 = p + o + r + t + e
a4 = t + a + p + i + s
a5 = a + s + t + r + e
a6 = p + a + t + r + e
a7 = l + o + t + u + s
a8 = l + i + s + t + e
a9 = l + o + u + p + e
a10 = o + u + t + r + e
IF (a1 < a2 AND a2 < a3 AND a3 < a4 AND a4 < a5 AND a5 < a6 AND a6 < a7 AND a7 < a8 AND a8 < a9 AND a9 < a10) THEN
PRINT a; e; i; o; u; l; p; r; s; t
PRINT a1; a2; a3; a4; a5; a6; a7; a8; a9; a10
PRINT #1, a; e; i; o; u; l; p; r; s; t
PRINT #1, a1; a2; a3; a4; a5; a6; a7; a8; a9; a10
END IF
used(s) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(u) = 0
END IF
NEXT
used(i) = 0
END IF
NEXT
used(e) = 0
END IF
NEXT
used(t) = 0
END IF
NEXT
used(p) = 0
END IF
NEXT
used(l) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
CLOSE 1
Yields: a e i o u l p r s t
6 8 5 3 9 4 2 0 1 7
Sum of Digits
18 19 20 21 22 23 24 25 26 27
|
Posted by brianjn
on 2009-11-21 19:15:47 |