Solve this alphametic, where each of the small letters in bold represents a different decimal digit from 0 to 9. None of the numbers can contain any leading zero.
(five)2 = (four)2 + (tri)2
(In reply to
Alphametric computer soltuion by Brian Smith)
Indeed:
DEFDBL A-Z
FOR f = 1 TO 9
used(f) = 1
FOR t = 1 TO 9
IF used(t) = 0 THEN
used(t) = 1
FOR i = 0 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR v = 0 TO 9
IF used(v) = 0 THEN
used(v) = 1
FOR e = 0 TO 9
IF used(e) = 0 THEN
used(e) = 1
five = f * 1000 + i * 100 + v * 10 + e
FOR o = 0 TO 9
IF used(o) = 0 THEN
used(o) = 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
four = f * 1000 + o * 100 + u * 10 + r
tri = t * 100 + r * 10 + i
IF five * five = four * four + tri * tri THEN
PRINT five; four; tri
END IF
used(r) = 0
END IF
NEXT
used(u) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(e) = 0
END IF
NEXT
used(v) = 0
END IF
NEXT
used(i) = 0
END IF
NEXT
used(t) = 0
END IF
NEXT
used(f) = 0
NEXT
produces
1496 1320 704
only.
|
Posted by Charlie
on 2009-04-18 17:27:21 |