DEFDBL A-Z
CLS
FOR c = 1 TO 9
used(c) = 1
FOR a = 1 TO 9
IF used(a) = 0 THEN
used(a) = 1
FOR b = 0 TO 9
IF used(b) = 0 THEN
used(b) = 1
FOR r = 1 TO 9
IF used(r) = 0 THEN
used(r) = 1
cab = 100 * c + 10 * a + b
pr1 = cab * r
IF pr1 > 99 AND pr1 < 1000 THEN
pr2 = cab * a
IF pr2 > 999 AND pr2 < 10000 THEN
pr3 = cab * c
IF pr3 > 999 AND pr3 < 10000 THEN
f = pr1 \ 100
IF used(f) = 0 THEN
used(f) = 1
u = (pr1 \ 10) MOD 10
IF used(u) = 0 THEN
used(u) = 1
IF r = pr1 MOD 10 THEN
IF pr2 \ 1000 = c AND pr3 \ 100 = 11 * b AND pr3 MOD 10 = c THEN
IF (pr2 \ 10) MOD 10 = (pr3 \ 10) MOD 10 THEN
PRINT cab; r, pr1; pr2; pr3
END IF
END IF
END IF
used(u) = 0
END IF
used(f) = 0
END IF
END IF
END IF
END IF
used(r) = 0
END IF
NEXT
used(b) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
used(c) = 0
NEXT
PRINT "-------"
FOR c = 1 TO 9
used(c) = 1
FOR a = 1 TO 9
IF used(a) = 0 THEN
used(a) = 1
FOR r = 0 TO 9
IF used(r) = 0 THEN
used(r) = 1
FOR b = 1 TO 9
IF used(b) = 0 THEN
used(b) = 1
car = 100 * c + 10 * a + r
pr1 = car * b
IF pr1 > 99 AND pr1 < 1000 THEN
pr2 = car * a
IF pr2 > 999 AND pr2 < 10000 THEN
pr3 = car * c
IF pr3 > 999 AND pr3 < 10000 THEN
IF pr1 = car THEN
u = (pr2) MOD 10
IF used(u) = 0 THEN
used(u) = 1
IF u = pr3 MOD 10 AND pr3 \ 100 = 11 * b THEN
IF used((pr3 \ 10) MOD 10) = 0 THEN
PRINT car; b, pr1; pr2; pr3
END IF
END IF
used(u) = 0
END IF
END IF
END IF
END IF
END IF
used(b) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT
used(c) = 0
NEXT
Finds
381 2 762 3048 1143
-------
382 1 382 3056 1146
384 1 384 3072 1152
showing two solutions for the second multiplication, but only one for the first.
In the first, CAR is 381 and B is 2. The three partial products are shown: 762 3048 1143.
Indeed, one of the two solutions for the second, 382*381 does match, in reverse order, the multiplication in the first alphametic.
This makes the first alphametic better, in having only one solution.
|
Posted by Charlie
on 2013-10-12 17:53:20 |