Given an amount, write a program to find a minimum number of currency notes of different denominations that sum to the given amount. Available note denominations are 1000, 500, 100, 50, 20, 5, 1.
For example, if the given amount is 8593, in this problem you have to give the minimum number of notes that sum up to the given amount. Since we only have notes with denomination 1000, 500, 100, 50, 20, 5 and 1, we can only use these notes.
1000:8
500:1
100:0
50:1
20:2
5:0
1:3
nominals = (1000, 500, 100, 50, 20, 5, 1)
amount = int(input('amount = '))
output = {}
for n in nominals:
output[n] = amount // n
amount %= n
for k, v in output.items():
print(k, v, sep=':')
Comments
Leave a comment