Without giving a full answer, can anyone give me an expected result of pset2 problem 3
you want the number but not the code?
lol@bwCA
Ok, scratch that i know i screwed up somewhere. Any Advice: #11:53 3/9/12 #McNugget Diophantine #MIT - OCW CIS 6.00 PSET2a bestsofar = 0 def mng (mcnuggets): ##mng = mcnuggetgrinder Pkg3 = 20 Pkg2 = 9 Pkg1 = 6 for numPkg3 in range (0, mcnuggets + 1, Pkg3): for numPkg2 in range (0, (mcnuggets + 1) - (numPkg3 * Pkg3), Pkg2): numPkg1x = mcnuggets - (numPkg3 * Pkg3) - (numPkg2 * Pkg2) if numPkg1x % 6 == 0: return True for n in range (1, 150): ## n = nuggets if mng(n) != True: if n > bestsofar: bestsofar = n print "Largest number of McNuggets that cannot be bought in exact quantity:", bestsofar
pls use a code pasting site: dpaste.com, pastebin.com, codepad.org, are a few - they all have syntax highlighting and the last will execute your script. your function needs to return False also, if appropriate if you have an expression that evaluates to a boolean, don't compare it to True or False in an if statement - just use it as is - http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#testing-for-truth-values http://pastebin.com/PMD4kmtf
I answered your question on the given link! The number is 149... http://codepad.org/2ploRkxf
149 is not the answer
Join our real-time social learning platform and learn together with your friends!