def greedy_coin_change(amount, coins): coins = sorted(coins, reverse=True) result = [] for coin in coins: while amount >= coin: amount -= coin result.append(coin) return result print(greedy_coin_change(63, [25, 10, 5, 1])) # [25, 25, 10, 1, 1, 1]
Click Run to execute this code.