ATM money counter
Description:
Imagine that we have ATM with multiple currencies. The users can withdraw money of in any currency that the ATM has.
Our function must analyze the currency and value of what the users wants, and give money to the user starting from bigger values to smaller. The ATM gives the least amount of notes possible.
This kata has a preloaded dictionary of possible bank note values for different currencies (RUB, EUR, UAH, USD, CUP, SOS
):
VALUES = { "EUR": [5, 10, 20, 50, 100, 200, 500], "USD": ... }
The function should return a string containing how many bank notes of each value the ATM will give out, for example:
"8 * 100 USD, 2 * 20 USD, 1 * 2 USD"
If it can't do that because there are no notes for this value, it should return:
"Can't do *value* *currency*. Value must be divisible by *amount*!"
(replace *value*
, *currency*
and *amount*
with the relevant details)
If it doesn't have the requested currency at all, it should return:
"Sorry, have no *currency*."
Notes:
- Letter case and word order doesn't matter in the input: e.g.
"EUR 1000"
and"1000eur"
are the same. See test cases for more user input samples. - Do not create your own
VALUES
dictionary/hash or you'll get broken tests.
Similar Kata:
Stats:
Created | Dec 7, 2015 |
Published | Dec 7, 2015 |
Warriors Trained | 2011 |
Total Skips | 89 |
Total Code Submissions | 5632 |
Total Times Completed | 687 |
Python Completions | 380 |
JavaScript Completions | 278 |
Ruby Completions | 48 |
Total Stars | 65 |
% of votes with a positive feedback rating | 90% of 190 |
Total "Very Satisfied" Votes | 162 |
Total "Somewhat Satisfied" Votes | 19 |
Total "Not Satisfied" Votes | 9 |
Total Rank Assessments | 8 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |