Files
exams/algorithms/labs/lab7/code/1.py
2025-10-01 22:55:09 +03:00

15 lines
384 B
Python

def greedy_change(n, coins):
result = []
for value, count in sorted(coins, key=lambda x: -x[0]):
while count > 0 and n >= value:
n -= value
count -= 1
result.append(value)
return result if n == 0 else None
if __name__ == "__main__":
coins = [(10, 3), (5, 2), (2, 5), (1, 10)]
N = 28
print(greedy_change(N, coins))