November 13, 2017
I got this text message from my father-in-law:
Ok. Soda 1.50 Chocolate bar 1.00 Gum 0.10 Jelly Bean .05
Have to buy exactly 14 items and spend $10
At least one of each.
There are 4 diff combos. (Order: soda, chocolate, gum and jelly bean)
Got 5-2-3-4 3-5-4-2
Can’t get others. Any ideas? :)
I whipped up this solution to check in python:
#!/usr/bin/python3 # created_at: 2017-11-13 13:53:19 -0800 def main(): solutions = 0 for si in range(1,7): for ci in range(1,11): for gi in range(1,101): for ji in range(1,201): total = si*150 + ci*100 + gi*10 + ji*5 items = si + ci + gi + ji if total == 1000 and items == 14: print(si,ci,gi,ji, total, items) solutions += 1 print(solutions) if __name__ == "__main__": main() The core of this solution is the check