Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checker(nuggets, packs):
- # First get the values out of `packs` for convenience.
- x, y, z = packs[0], packs[1], packs[2]
- # Check the truth of the equation for every
- # permutation.
- for a in range(nuggets):
- for b in range(nuggets):
- for c in range(nuggets):
- if (x*a) + (y*b) + (z*c) == nuggets:
- return True
- def do():
- # get pack sizes
- packs = []
- while len(packs) < 3:
- usrin = raw_input('Enter a pack size: ')
- try:
- if int(usrin) > 1:
- if not int(usrin) in packs:
- packs.append(int(usrin))
- else:
- print '// You already entered', usrin
- else:
- print '...that\'s greater than one??'
- except:
- print 'Huh?...'
- # Check every number that's less than 200 to find the
- # highest number that can not be purchased evenly.
- tally = 200
- while tally:
- tally -= 1
- if not checker(tally, packs):
- return str(tally)
- print '''
- #######################################
- #> Welcome to MuckNugget Checker <#
- #######################################
- '''
- bye_message = '''
- = = = = = = = = = =
- | God Bless |
- = = = = = = = = = =
- '''
- loop = True
- while loop:
- # This print statement can not run until its call to `do()` has
- # returned. The `do()` function will print its input prompts
- # before it returns and allows this to print.
- print '''
- The greatest number below 200 that can
- not be purchased in the pack sizes you
- have entered is ''' +do()+ '.\n'
- if raw_input('Press Enter to continue.\nAnything else to quit. '):
- print bye_message
- loop = False
- else:
- print '\n Let\'s go again...\n'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement