solve a newspaper quiz

superpollo utente at esempio.net
Sun May 9 05:20:35 EDT 2010


"if a b c are digits, solve ab:c=a*c+b"

solved in one minute with no thought:

for a in range(10):
     for b in range(10):
         for c in range(10):
             try:
                 if (10.*a+b)/c==a*c+b:
                     print "%i%i:%i=%i*%i+%i" % (a,b,c,a,c,b)
             except:
                 pass

any suggestion for improvement?

bye



More information about the Python-list mailing list