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

Mel mwilson at the-wire.com
Sun Aug 15 21:15:34 CEST 2010


Baba wrote:

> Hi All,
> 
> @Emile tnx for spotting the mistake. Should have seen it 
myself.
> 
> @John & Ian i had a look around but couldn't find a general 
version of
> below theorem
> If it is possible to buy x, x+1,…, x+5 sets of McNuggets, 
for some x,
> then it is possible to buy any number of McNuggets >= x, 
given that
> McNuggets come in 6, 9 and 20 packs.

Not that hard.  When you can buy nuggets `n` to a pack (6 for 
example) then if you have schemes for buying 
k,k+1,k+2,...,k+n-1 nuggets, you can create a scheme for 
buying any number of nuggets >= k .  At worst just buy packs 
of `n` until the number left to buy is between k and k+n-1 
inclusive, then follow the scheme for that number.

	Mel.




More information about the Python-list mailing list