Determine the quotient, divisor and the dividend from this incomplete division:
H * B
+-----------
A B| * G C D *
* * I
---------
F F *
G *
-----------
A H F
A H F
--------
639
+------
29|18531
174
-----
113
87
-----
261
261
-----
I rewrote the original problem with lowercase letters in place of asterisks and set up several variable names:
H q B quot
+-----------
A B| r G C D s one
t w I two
---------
F F x three
G y four
-----------
A H F five
A H F six
--------
program output
2 9 5 3 1 8 6 4
29 639 18531 174 113 87
--------------------------
for A in range(10):
for B in range(10):
if A==B:
continue
AB = 10*A + B
for H in range(10):
if H in [A,B]:
continue
for q in range(10):
quot = 100*H + 10*q + B
one = AB*quot
if len(str(one)) != 5:
continue
G = int(str(one)[1])
C = int(str(one)[2])
D = int(str(one)[3])
if G in [A,B,H]:
continue
if C in [A,B,H,G]:
continue
if D in [A,B,H,G,C]:
continue
two = H * AB
if len(str(two)) != 3:
continue
I = two%10
if I in [A,B,H,G,C,D]:
continue
three = (one//100 - two)*10 + D
if len(str(three)) != 3:
continue
F = int(str(three)[0])
if int(str(three)[1]) != F:
continue
if F in [A,B,H,G,C,D,I]:
continue
four = q * AB
AH = three - four
if AH != 10*A + H:
continue
print(A,B,C,D,F,G,H,I)
print(AB,quot,one,two,three,four)
|
Posted by Larry
on 2024-02-08 00:04:03 |