Another math problem easier to solve by hand, but, IMHO, difficult to program in a concise way like the solution of Bill Mill (linalg_brute.py) to the problem of engsol.
I appreciated very much the Bill Mill's solution and that inspired in a certain way the solution for my problem. # Problem and solution: # ab * cb = dab 35 * 26 = 936 # + + - + + - # ifd + chg = eaf 179 + 258 = 437 # --------------- --------------- # cih + cge = edd 215 + 284 = 499 >From that you can get 6 equations: # equation n. 1 : (10a+b) * ( 10c+b) = 100d+10a+b # equation n. 2 : 100i+ f d + 100c+ h g = e+ a f # equation n. 3 : c+ i h + c g e = e d d # equation n. 4 : ( a b) + i f d = c i h # equation n. 5 : ( c b) + c h g = c g e # equation n. 6 : d+ a b - e a f = e d d (I removed most of digit part to enhance the variables). My solution: def Hund(w): # hundreths . return int(w/100) def Ten2(w): # tenths for 2 digits . return int(w/10) def Ten(w): # tenths for 3 digits . return int((w%100)/10) def Unit(w): # units . return w%10 nc = range(100,1000) # range of 3 digits numbers nd = range(10,100) # range of 2 digits numbers def eq_1(): . return [(x,y,z) for x in nd \ . for y in nd \ . for z in nc \ . if x*y-z == 0 \ . and Unit(x) == Unit(y) \ . and Unit(x) == Unit(z) \ . and Ten2(x) == Ten(z) \ . and Ten2(x) != Ten2(y) ] lResult1=eq_1() print lResult1 >From the results you can choose other equations to treat with the same approach. I know it's a rather long process.. but that is the best I can do. -- http://mail.python.org/mailman/listinfo/python-list