- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Summary
Implement an ATM method that properly dispenses the correct denominations to a user.
Exercise Description
Build out a method that takes two arguments: the total amount of money requested and the denominations that can be returned. And return the count of how many bills of each denomination should be returned to a user.
Example Data Input
245, [20, 10, 5]
In this example, 245
is the total amount requested at the ATM, and the array represents 20
, 10
, and 5
dollar bills.
Expected Output
{20=>12, 10=>0, 5=>1}
This hash represents 12
$20 dollar bills and 1
$5 dollar bills.
Real World Usage
This exercise is a very popular Ruby coding interview question. This will test your knowledge of several mathematical methods along with how you can combine multiple functional programming concepts.