Why doesn't this code work? PSet 2 #3 ctr = 1 n = 1 while ctr < 6: for a in range(0, n): for b in range(0, n): for c in range(0, n): if (6 * a) + (9 * b) + (20 * c) == n: print ctr, 'a, b, c =',a,b,c ctr += 1 n += 1 else: n += 1 if x == 6: print n,'is the highest number of McNuggests'

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Why doesn't this code work? PSet 2 #3 ctr = 1 n = 1 while ctr < 6: for a in range(0, n): for b in range(0, n): for c in range(0, n): if (6 * a) + (9 * b) + (20 * c) == n: print ctr, 'a, b, c =',a,b,c ctr += 1 n += 1 else: n += 1 if x == 6: print n,'is the highest number of McNuggests'

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Why does this version work but not my originally listed: ctr = 1 n = 1 nugget_purchase = False while ctr < 6: for a in range(0, n): for b in range(0, n): for c in range(0, n): if (6 * a) + (9 * b) + (20 * c) == n: print a,b,c,'lead to nugget purchase',n nugget_purchase = True if nugget_purchase == True: ctr += 1 nugget_purchase = False elif nugget_purchase == False: print n,'cannot be bought' ctr = 1 n += 1 print n
Your first code it incremented your ctr and your n under your for loop which means that for every number in the for loop it would add 1 to ctr and n if an answer was found.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question