β back to unit
Challenge
# puzzle gauntlet advanced
The Snack Machine
Be the machine: check the stock, check the coins, count out change like a pro. π€π«
You get the menu as item:price pairs, the stock as item:count pairs, then an order line item,coins. Print sold out if stock is 0, not enough if the coins can't cover the price β otherwise change <k> coins, where k is the FEWEST coins (25/10/5/1) making up coins minus price.
Example:
Input: menu = "cola:65,chips:40", stock = "cola:2,chips:0", order = "cola,100"
Output: change 2 coins
cola is in stock and 100 covers the 65 price, leaving 35 change β made from one 25 and one 10, that's 2 coins.
π‘ need a hint?
pg-snack-machine.pyπ given lines are locked β write your code in between
loading...