Currency
Created on June 12, 2021 by Julien Palard
Write a function named how_to_pay
taking two parameters: amount
and currency
.
amount
is an amount to pay.currency
describe the currency as a list of existing coins or banknotes.
The function should return a dict
describing the easiest way to pay
amount
with the given currency
.
For example, to pay 3
with a currency having coins of [1, 2, 5]
you have to use one coin of 2
and one coin of 1
, so the function
should return {2: 1, 1: 1}
.
Usage example
1 2 3 4 5 6 7 8 |
|
Hint
It is OK to explicitly tell there's no need of a specific coin, but not mandatory, both are good to me. I mean both are valid answers:
1 2 3 4 |
|
There's no corrections yet, hit the `Submit` button to send your code to the correction bot.
Keyboard shortcuts:
- Ctrl-Enter: Send your code to the correction bot.
- Escape: Get back to the instructions tab.