Tabulate Minimum Coin Count
Fill a table of the fewest coins for every amount from 0 up to the target.
The problem
Implement minimum_coin_count(coins, amount). coins lists positive coin values, and you may use each value as many times as you like. Return the fewest coins whose values add up to amount, or -1 if no combination works. For example, with coins [1, 3, 4] and amount 6 the answer is 2 (3 + 3), and with coins [2, 4] amount 7 cannot be made, so the answer is -1. An amount of 0 needs 0 coins. Constraints: 1 to 12 coin values, each at most 2**31 - 1, and 0 <= amount <= 10000.
Starter code
def minimum_coin_count(coins, amount):
passPublic examples
coins = [1, 3, 4], amount = 6gives2coins = [2, 4], amount = 7gives-1coins = [2], amount = 6gives3
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
