[Tutor] Problem
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Aug 28 19:17:20 EDT 2016
On 28/08/16 15:46, shahan khan wrote:
> 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.
>
> Here is my code:
> for a in range(1,10):
> for b in range(1,5):
> for c in range(1,5):
> mc=(6*a)+(9*b)+(20*c)
> if mc==50:
> print a,b,c
> else:
> print a,b,c
> a=+1
> b=b+1
> c=c+1
Its hard to be sure what you are tying to do here because the formattng
is messed up. Please post in plain text. For example it could be:
for a in range(1,10):
for b in range(1,5):
for c in range(1,5):
mc=(6*a)+(9*b)+(20*c)
if mc==50:
print a,b,c
else:
print a,b,c
a=+1
b=b+1
c=c+1
But its not clear why you are adding 1 to a,b and c?
And I'm not sure why the inner loops are both up to 4.
I don't really understand what you are trying to do or
how you think this code will do it, so I can't offer
you more help.
Sorry.
Alan g
More information about the Tutor
mailing list