Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
native_making_change solution in Clear category for Making Change by Jon_Red
def checkio(price,denominations):
t=[0]+[price+1]*price
for x in range(1,len(t)):
for y in[z for z in denominations if z<=x]:t[x]=min(t[x-y]+1,t[x])
return t[price]if t[price]<=price else None
if __name__ == '__main__':
# self-checks
assert checkio(8,[1,3,5])==2
assert checkio(12,[1,4,5])==3
July 18, 2020