Advertisement
makispaiktis

Greedy Algorithms - Coins

May 29th, 2020 (edited)
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. n = 72
  2. c = [1, 5, 10, 25]
  3.  
  4. def coins(n, c):
  5.     for i in range(len(c)):
  6.         max_coin = c[len(c)-1-i]
  7.         print(max_coin, 'x', n//max_coin)
  8.         n -= (n//max_coin) * max_coin
  9.  
  10. print("For " + str(n))
  11. coins(n, c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement