DEFDBL A-Z
FOR w = 1 TO 9
used(w) = 1
FOR r = 1 TO 9
IF used(r) = 0 THEN
used(r) = 1
FOR o = 0 TO 9
IF used(o) = 0 THEN
used(o) = 1
FOR n = 0 TO 9
IF used(n) = 0 THEN
used(n) = 1
FOR g = 0 TO 9
IF used(g) = 0 THEN
used(g) = 1
wrong = w * 10000 + r * 1000 + o * 100 + n * 10 + g
test$ = LTRIM$(STR$(2 * wrong))
IF LEN(test$) = 5 THEN
IF VAL(MID$(test$, 1, 1)) = r AND VAL(MID$(test$, 3, 1)) = g THEN
i = VAL(MID$(test$, 2, 1))
h = VAL(MID$(test$, 4, 1))
t = VAL(MID$(test$, 5, 1))
IF used(i) = 0 AND used(h) = 0 AND used(t) = 0 THEN
IF i <> h AND i <> t AND h <> t THEN
PRINT wrong, test$
ct = ct + 1
END IF
END IF
END IF
END IF
used(g) = 0
END IF
NEXT
used(n) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(w) = 0
NEXT
PRINT ct
finds what I assume is the expected solution:
wrong right
12734 25468
12867 25734
12938 25876
24153 48306
24765 49530
25173 50346
25193 50386
25418 50836
25438 50876
25469 50938
25734 51468
25867 51734
25938 51876
37081 74162
37091 74182
37806 75612
37846 75692
37908 75816
49153 98306
49265 98530
49306 98612
21 solutions in all for the decimal version.
But, taking this further:
In base 9:
DEFDBL A-Z
FOR w = 1 TO 8
used(w) = 1
FOR r = 1 TO 8
IF used(r) = 0 THEN
used(r) = 1
FOR o = 0 TO 8
IF used(o) = 0 THEN
used(o) = 1
FOR n = 0 TO 8
IF used(n) = 0 THEN
used(n) = 1
FOR g = 0 TO 8
IF used(g) = 0 THEN
used(g) = 1
wrong = w * 6561 + r * 729 + o * 81 + n * 9 + g
test$ = ""
tst = 2 * wrong
DO
d$ = LTRIM$(STR$(tst MOD 9))
tst = tst \ 9
test$ = d$ + test$
LOOP UNTIL tst = 0
IF LEN(test$) = 5 THEN
IF VAL(MID$(test$, 1, 1)) = r AND VAL(MID$(test$, 3, 1)) = g THEN
i = VAL(MID$(test$, 2, 1))
h = VAL(MID$(test$, 4, 1))
t = VAL(MID$(test$, 5, 1))
IF used(i) = 0 AND used(h) = 0 AND used(t) = 0 THEN
IF i <> h AND i <> t AND h <> t THEN
PRINT w; r; o; n; g, test$
ct = ct + 1
END IF
END IF
END IF
END IF
used(g) = 0
END IF
NEXT
used(n) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(w) = 0
NEXT
PRINT ct
w r o n g right
1 2 7 4 6 25603
2 4 1 7 3 48356
3 7 5 4 1 76182
just 3 solutions.
And in base 11:
DEFDBL A-Z
FOR w = 1 TO 10
used(w) = 1
FOR r = 1 TO 10
IF used(r) = 0 THEN
used(r) = 1
FOR o = 0 TO 10
IF used(o) = 0 THEN
used(o) = 1
FOR n = 0 TO 10
IF used(n) = 0 THEN
used(n) = 1
FOR g = 0 TO 10
IF used(g) = 0 THEN
used(g) = 1
wrong = w * 14641 + r * 1331 + o * 121 + n * 11 + g
test$ = ""
tst = 2 * wrong
DO
d$ = MID$("0123456789abcdef", (tst MOD 11) + 1, 1)
tst = tst \ 11
test$ = d$ + test$
LOOP UNTIL tst = 0
IF LEN(test$) = 5 THEN
r2 = INSTR("0123456789abcdef", MID$(test$, 1, 1)) - 1
g2 = INSTR("0123456789abcdef", MID$(test$, 3, 1)) - 1
i = INSTR("0123456789abcdef", MID$(test$, 2, 1)) - 1
h = INSTR("0123456789abcdef", MID$(test$, 4, 1)) - 1
t = INSTR("0123456789abcdef", MID$(test$, 5, 1)) - 1
IF r2 = r AND g2 = g THEN
IF used(i) = 0 AND used(h) = 0 AND used(t) = 0 THEN
IF i <> h AND i <> t AND h <> t THEN
PRINT w; r; o; n; g, test$
ct = ct + 1
END IF
END IF
END IF
END IF
used(g) = 0
END IF
NEXT
used(n) = 0
END IF
NEXT
used(o) = 0
END IF
NEXT
used(r) = 0
END IF
NEXT
used(w) = 0
NEXT
PRINT ct
w r o n g right
1 2 5 3 10 24a79
1 2 7 4 3 25386
1 2 7 10 4 25498
2 4 1 9 3 48376
2 4 1 10 3 48396
2 4 5 0 10 48a19
2 4 5 1 10 48a39
2 4 5 3 10 48a79
2 4 7 5 3 493a6
2 4 8 3 5 4956a
2 4 8 5 6 49601
2 5 7 4 3 50386
2 5 7 6 4 50418
2 5 7 10 4 50498
2 5 8 7 6 50641
2 5 10 1 9 50937
3 7 6 5 1 741a2
3 7 8 1 5 7452a
3 7 8 5 6 74601
3 7 9 6 8 74825
4 9 0 8 1 97152
4 9 1 8 3 97356
4 9 2 6 5 9751a
4 9 3 2 6 97651
4 9 6 5 1 981a2
4 9 7 1 3 98326
4 9 7 5 3 983a6
fully 27 solutions.
Note the successor to 9 is shown as 10 for wrong, but as a for right.
But 49 are found for base 12:
1 2 3 5 6 246b0
1 2 5 3 10 24a78
1 2 5 7 11 24b3a
1 2 5 9 11 24b7a
1 2 7 8 3 25346
1 2 7 10 3 25386
1 2 7 11 3 253a6
1 2 9 3 6 25670
1 2 10 3 8 25874
1 2 10 7 9 25936
1 2 11 3 10 25a78
1 2 11 4 10 25a98
2 4 1 11 3 483a6
2 4 3 5 6 486b0
2 4 5 6 11 48b1a
2 4 5 7 11 48b3a
2 4 5 9 11 48b7a
2 4 7 10 3 49386
2 4 7 11 3 493a6
2 4 8 6 5 4950a
2 4 11 0 10 49a18
2 4 11 1 10 49a38
2 4 11 3 10 49a78
3 7 4 8 9 72956
3 7 5 0 10 72a18
3 7 5 4 10 72a98
3 7 5 6 11 72b1a
4 9 0 10 1 96182
4 9 0 11 1 961a2
4 9 3 8 7 96752
4 9 5 0 10 96a18
4 9 5 1 10 96a38
4 9 5 3 10 96a78
4 9 5 7 11 96b3a
4 9 6 10 1 97182
4 9 6 11 1 971a2
4 9 8 6 5 9750a
4 9 11 0 10 97a18
4 9 11 1 10 97a38
4 9 11 2 10 97a58
5 11 0 8 1 ba142
5 11 0 9 1 ba162
5 11 1 3 2 ba264
5 11 1 7 3 ba326
5 11 1 8 3 ba346
5 11 2 3 4 ba468
5 11 3 4 6 ba690
5 11 3 6 7 ba712
5 11 4 7 9 ba936
It seems the trend is an increasing number the higher the base.
|
Posted by Charlie
on 2010-11-22 18:15:41 |