In this cryptarithm, each letter above the line represents a digit differing by 1 from the digit represented by the same letter below the line. For example, if A=3 above the line, then A=2 or A=4 below the line. All occurrences of a letter on the same side of a line represent the same digit. It is also known that there are total of five digits in the solution.
ADABA
+CACBA
------
DBABC
FOR a = 1 TO 9
FOR b = 0 TO 9
IF b <> a THEN
FOR c = 1 TO 9
IF c <> a AND c <> b THEN
FOR d = 0 TO 9
IF d <> c AND d <> b AND d <> a THEN
top = a * 10101 + d * 1000 + b * 10
bottom = c * 10100 + a * 1001 + b * 10
tot = top + bottom
t$ = LTRIM$(STR$(tot))
IF LEN(t$) = 5 THEN
IF MID$(t$, 2, 1) = MID$(t$, 4, 1) THEN
IF ABS(VAL(MID$(t$, 3, 1)) - a) = 1 THEN
IF ABS(VAL(MID$(t$, 2, 1)) - b) = 1 THEN
IF ABS(VAL(MID$(t$, 5, 1)) - c) = 1 THEN
IF ABS(VAL(MID$(t$, 1, 1)) - d) = 1 THEN
PRINT top: PRINT bottom: PRINT tot
END IF
END IF
END IF
END IF
END IF
END IF
END IF
NEXT d
END IF
NEXT c
END IF
NEXT b
NEXT a
finds
56505
15105
71610
|
Posted by Charlie
on 2004-08-11 13:24:39 |