Given string S
representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value.
Coin : Value
Dollar Coins : $1.00
Quarters: $0.25
Dimes: $0.10
Nickels: $0.05
Pennies: $0.01
Input
String S
that contains the dollar symbol $
and the dollar amount.
Output
List of coin numbers separated by a space character " "
. The list must be in this order: Dollar coins, quarters, dimes, nickels, pennies.
Constraints
$0.00 < S < $10.00
S
is given to two decimal places.- make change for that amount of money use the least number of coins
Example Input
$4.58
$9.99
Output
4 2 0 1 3
9 3 2 0 4
Win Condition
shortest bytes win.
$
sign in the input? I suggest allowing the number itself, either as a number or a string (optional). \$\endgroup\$$
-sign requirement in the input, and make the output format optional... \$\endgroup\$$d.dd
, the symbols give no information and so just need to be stripped away or ignored. \$\endgroup\$