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

Ian Kelly ian.g.kelly at gmail.com
Fri Aug 13 15:25:07 EDT 2010


On Fri, Aug 13, 2010 at 12:25 PM, Baba <raoulbia at gmail.com> wrote:
> Hi News 123,
>
> Ok i'm getting closer. I am able to write code that will output values
> that can be bought in exact quantity (truelist) and values that cannot
> be bought in exact quantities.
>
> For a range up to 29 i get this:
> true [6, 9, 12, 15, 18, 20, 21, 24, 26, 27, 29]
> false [0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 22, 23, 25,
> 28]
>
> the sixth value that passes the test of having an exact solution is 20
> so that would mean that the last number i got that cannot be bought in
> exact quantity is 19
>
> that doesn't seem quite right, does it?

It's not.  You're not just trying to find the sixth value that can be
bought in exact quantity, but a sequence of six values that can all be
bought in exact quantity.  The integers [6, 9, 12, 15, 18, 20] are not
sequential.



More information about the Python-list mailing list