12345 * 8 = 98760
87456 / 8 = 10932
DECLARE SUB permute (a$)
dig$ = "0123456789"
FOR strt = 1 TO 6
n$ = MID$(dig$, strt, 5)
nh$ = n$
DO
IF LEFT$(n$, 1) <> "0" THEN
n2$ = LTRIM$(STR$(8 * VAL(n$)))
con$ = n$ + n2$
IF LEN(con$) = 10 THEN
good = 1
FOR i = 1 TO 9
IF INSTR(MID$(con$, i + 1), MID$(con$, i, 1)) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT n$; " * 8 = "; n2$
END IF
END IF
permute n$
LOOP UNTIL n$ = nh$
NEXT
FOR strt = 1 TO 6
n$ = MID$(dig$, strt, 5)
nh$ = n$
DO
IF LEFT$(n$, 1) <> "0" AND VAL(n$) MOD 8 = 0 THEN
n2$ = LTRIM$(STR$(VAL(n$) / 8))
con$ = n$ + n2$
IF LEN(con$) = 10 THEN
good = 1
FOR i = 1 TO 9
IF INSTR(MID$(con$, i + 1), MID$(con$, i, 1)) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT n$; " / 8 = "; n2$
END IF
END IF
permute n$
LOOP UNTIL n$ = nh$
NEXT
The permute subroutine is defined elsewhere on the site
From Enigma # 1408, New Scientist, 9 September 2006. |