Build an ATM Dispensing Method in Ruby

This guide walks through how to build out the common Ruby coding interview question: how to build out an ATM dispensing method.


Implement an ATM method that properly dispenses the correct denominations to a user.

Exercise File

Code File

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.


Can be found on the solutions branch on github.

Jordan Hudgens

view all post
Leave a comment

Please be polite. We appreciate that.

By Daniele Zedda • 18 February


By Daniele Zedda • 18 February

Share on