def checkio(price, denominations):
temp = []
for i in range(0, price // denominations[0] + 1):
for j in range(0, price // denominations[1] + 1):
for k in range(0, price // denominations[2] + 1):
if price == denominations[0] * i + denominations[1] * j + denominations[2] * k:
temp.append(i+j+k)
if not temp:
return None
else:
return min(temp)
I don't know how can modify my codes if len(denominations) != 3.
Created at: 2017/12/22 04:33; Updated at: 2018/01/24 02:52
The question is resolved.