# Assume you can buy chicken nuggets in batches of 4- 8- and 24- What is.docx

4 de Feb de 2023
1 de 2

### Assume you can buy chicken nuggets in batches of 4- 8- and 24- What is.docx

• 1. Assume you can buy chicken nuggets in batches of 4, 8, and 24. What is the largest number of chicken nuggets that you cannot buy? Solution This code for find out the largest number of chicken nuggets that you cannot buy, using python. you can find out any type of batches using this. def solution_exists(amt, pieces, i=None): if i is None: i = len(pieces) - p = pieces[i] if i: return any(solution_exists(amt - p*k, pieces, i-1) for k in range(amt // p + 1)) else: return amt % p == 0 def find_max_unbuyable(pieces): least = min(pieces) n = 0 last_unsolved = None consecutive = 0 while consecutive < least:
• 2. n += 1 if solution_exists(n, pieces): consecutive += 1 else: last_unsolved = n consecutive = 0 return last_unsolved def main(): pieces = [4,8,24] max_unbuyable = find_max_unbuyable(pieces) print("Largest number of McNuggets that cannot be bought in exact quantity: {n}".format(n=max_unbuyable)) if __name__=="__main__": main()