python-McNuggets
Posted
by challarao
on Stack Overflow
See other posts from Stack Overflow
or by challarao
Published on 2010-06-17T05:05:53Z
Indexed on
2010/06/17
5:13 UTC
Read the original article
Hit count: 212
python
I have created some program for this.But printed a,b,c values are not correct.Please check this weather it is correct or not?
n=input("Enter the no.of McNuggets:")
a,b,c=0,0,0
count=0
for a in range(n):
if 6*a+9*b+20*c==n:
count=count+1
break
else:
for b in range(n):
if 6*a+9*b+20*c==n:
count=count+1
break
else:
for c in range(n):
if 6*a+9*b+20*c==n:
count=count+1
break
if count>0:
print "It is possible to buy exactly",n,"packs of McNuggetss",a,b,c
else:
print "It is not possible to buy"
© Stack Overflow or respective owner