Solve this long division problem, where each of the x's represent a decimal digit from 0 to 9, whether same or different. None of the numbers may contain any leading zero.
x x x x x

x x  x x x x 0 0 0
x x

x x x
x x

x 0
x x

x x 0
x x x

x 0
x 0

Note: Try to derive a non computer program assisted method, although computer program/spreadsheet solutions are welcome.
DEFDBL AZ
FOR dnd = 1000000 TO 9999000 STEP 1000
FOR dvr = 10 TO 99
IF dnd MOD dvr = 0 THEN
q = (dnd \ 10000) \ dvr
r = (dnd \ 10000) MOD dvr
IF q >= 1 AND q <= 9 AND q * dvr >= 10 AND q * dvr <= 99 AND r >= 10 AND r <= 99 THEN
d = r * 10 + (dnd \ 1000) MOD 10
q = d \ dvr: r = d MOD dvr
s = q * dvr
IF s >= 10 AND s <= 99 THEN
diff = d  s
IF diff >= 1 AND diff <= 9 THEN
d = 10 * diff
q = d \ dvr: r = d MOD dvr
s = q * dvr
IF s >= 10 AND s <= 99 THEN
diff = d  s
IF diff >= 10 AND diff <= 99 THEN
d = 10 * diff
q = d \ dvr: r = d MOD dvr
s = q * dvr
IF s >= 100 AND s <= 999 THEN
diff = d  s
IF diff >= 1 AND diff <= 9 THEN
d = 10 * diff
q = d \ dvr: r = d MOD dvr
s = q * dvr
IF r = 0 THEN
PRINT dvr, dnd
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
NEXT
NEXT
PRINT ct
finds
16 divided into 1062000
which comes out as
66375
16  1062000
96
102
96
60
48
120
112
80
80

Posted by Charlie
on 20090112 17:25:26 