Skip to content
Code ReadingCoin Table
Predict the Output

Coin Table

best[x] is the fewest coins that make x. What is printed once the table is filled?
1coins = [1, 3, 4]
2best = [0] * 6
3for amount in range(1, 6):
4 best[amount] = min(best[amount - c] for c in coins if c <= amount) + 1
5print(best)