(In reply to
Proverbs and alphametics don't mix??? by Steve Herman)
Discerning the 3 letters is easy enough however the listing below was written to evaluate the two equations:
W3+W2=W1
W3-W2=W4
Unfortunately it returns a blank screen.
FOR a = 0 TO 9
IF used(a) = 0 THEN
used(a) = 1
FOR b = 0 TO 9
IF used(b) = 0 THEN
used(b) = 1
FOR c = 0 TO 9
IF used(c) = 0 THEN
used(c) = 1
FOR e = 0 TO 9
IF used(e) = 0 THEN
used(e) = 1
FOR l = 1 TO 9
IF used(l) = 0 THEN
used(l) = 1
FOR m = 1 TO 9
IF used(m) = 0 THEN
used(m) = 1
FOR o = 0 TO 9
IF used(o) = 0 THEN
used(o) = 1
FOR r = 1 TO 9
IF used(r) = 0 THEN
used(r) = 1
FOR w = 1 TO 9
IF used(w) = 0 THEN
used(w) = 1
w1 = w * 1000 + o * 100 + r * 10 + m
w2 = l * 1000 + a * 100 + m * 10 + b
w3 = r * 1000 + a * 100 + c * 10 + e
w4 = m * 1000 + o * 100 + o * 10 + r
IF w1 = w3 + w2 AND w4 = w3 - w2 THEN REM advice in a later comment is that this assignment is incorrect.
PRINT w1; w2; w3; w4
END IF
used(w) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(m) = 0
END IF
NEXT
used(l) = 0
END IF
NEXT
used(e) = 0
END IF
NEXT
used(c) = 0
END IF
NEXT
used(b) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
Edited on February 17, 2013, 6:35 am
|
Posted by brianjn
on 2013-02-16 22:16:51 |