looping through possible combinations of McNuggets packs of 6,9 and 20

Martin P. Hellwig martin.hellwig at dcuktec.org
Thu Aug 12 15:56:15 EDT 2010


On 08/11/10 21:14, Baba wrote:
<cut>

How about rephrasing that question in your mind first, i.e.:

For every number that is one higher then the previous one*:
     If this number is dividable by:
         6 or 9 or 20 or any combination of 6, 9, 20
             than this number _can_ be bought in an exact number
     else
         print this number

* There are an infinite amount of numbers, just imagine the biggest
number you can think of and I say plus 1 :-)


Next thing you have to do is figure out how to write this in python,
particularly getting all the combinations of divisions can be tricky.
Hint; you are not really interested in the division result but rather if 
a division would be complete or give a remainder (modulo operator).
If you get an remainder this could be okay if that can divided by one of 
the other numbers, and so forth till you ran out of combinations.

-- 
mph



More information about the Python-list mailing list