Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_coins(value: int, coins: tuple):
- if not isinstance(value, int):
- raise ValueError("Only Integers are allowed.")
- if not all(isinstance(element, int) for element in coins):
- raise ValueError("Coins must be all integer.")
- result = {}
- for coin in coins:
- multi = value // coin
- if multi:
- value -= coin * multi
- result[coin] = multi
- return result, value
- coins = (100, 50, 20, 10, 5, 2, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement