Overview
In the US, the common denominations are the penny ($0.01), the nickel ($0.05), the dime ($0.10), the quarter ($0.25), one dollar, two dollars (less common but lets pretend it's common), five dollars, ten dollars, twenty dollars, fifty dollars, and one hundred dollars. ($1 to $100 respectively).
Your goal is to take an arbitrary money value and output a list of the fewest bills and coins that add up to that amount.
Rules
- The output must be minimal. You cannot output "4175 pennies" for $41.75.
- The inputs and outputs can be any format or type, as long as you can explain what it means.
- Values must be kept the same. For instance, your program cannot accept "6523" for $65.23. It must accept the decimal value "65.23"
Examples
If the input is $185.24, the output should be something like
$100 + $50 + $20 + $10 + $5 + $0.10 + $0.10 + $0.01 + $0.01 + $0.01 + $0.01
For the input $44.75, another acceptable output would be
[0, 0, 2, 0, 0, 2, 0, 3, 0, 0, 0]
Meaning 2 $20s, 2 $2s, 3 quarters, and 0 of the other denominations.
Bonus
Accept another argument for the list of denominations so your program will work in other countries.
For example, if it's given this list of denominations.
[15, 7, 2.5, 1, 0.88, 0.2, 0.01]
and the money value "37.6", it should return something like
15 + 15 + 7 + 0.2 + 0.2 + 0.2