On 08/11/2010 10:14 PM, Baba wrote:
> level: beginner
> 
> exercise: given that packs of McNuggets can only be bought in 6, 9 or
> 20 packs, write an exhaustive search to find the largest number of
> McNuggets that cannot be bought in exact quantity.
> 
> exercise source:
> http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset2.pdf
> 
> please help me write this code
> 
> i believe it's something along the lines of this:
> 
> c=0
> sol=[]
> for n in range (0,10):
>  for a in range (0,10):
>   for b in range (0,10):
>    for c in range (0,10):
>     sol=6*a+9*b+20*c
>     if sol!=n:
>      c+=1
>     if c==6:
>      print sol
> 

If you're interested in more, than just finishing the exercise, then you
should post your solution even if you have it already and read about all
the tips how to make it faster or shorter or more readable
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to