Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def nuggetguide(target):
- """For a given number, tells you how many of each nugget packages to buy to add up to n"""
- S=0#all initial values at zero
- M=0
- L=0
- for L in range(0,target/20+1):#the large box will have at least 20 pieces so...
- for M in range(0,target/9+1):
- for S in range(0,target/6+1):
- if target == S*6 + M*9 + L*20:#then we have our answer.
- return (S, M, L)#return the answer
- return "No solutions"#if the whole thing runs and it doesn't find an answer, return No solutions.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement