Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
8-liner: Dynamic Programming Implementation solution in Clear category for Making Change by Stensen
def checkio(price, denominations):
minimum_coins = [10000]*(price+1)
minimum_coins[0] = 0
for i in range(1, price + 1):
for j in denominations:
if i - j > -1:
minimum_coins[i] = min(minimum_coins[i], minimum_coins[i - j] + 1)
return minimum_coins[price] if minimum_coins[price] != 10000 else None
March 26, 2022