On 8/15/2010 11:38 AM, Baba wrote: In addition to the points that Emile and Ian made ...
def diophantine_nuggets(x,y,z): cbc=0 #cbc=can_buy counter packages =[x,y,z]
You can take advantage of a nifty "syntax convenience feature" here. Instead of loading all of the function's arguments into a list "manually", you can make it happen automatically:
def diophantine_nuggets(x,y,z): cbc = 0 packages =[x,y,z] ... becomes ... def diophantine_nuggets(*packages): cbc = 0 The asterisk (*) in the function's signature does the trick.
for n_nuggets in range(50):
Careful -- in the general case, you might need to search beyond 50 for your answer!
Best, John -- http://mail.python.org/mailman/listinfo/python-list