Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def combinations1(amount,denominations):
  2.  
  3. """Funkcja combinations1 przyjmuje jako pierwszy argument kwotę (intiger) i nominały (listę zmiennych typu intiger)
  4. jako drugi argument,
  5. zwraca ilość kombinacji jakie można utworzyć z listy nominałów by uzyskać podaną kwotę"""
  6.  
  7. if amount == 0:
  8. return 1
  9.  
  10. elif amount<0:
  11. return 0
  12.  
  13. elif len(denominations)==0:
  14. return 0
  15.  
  16. return combinations1(amount,denominations[1:])+ combinations1(amount-denominations[0],denominations)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement