6 kyu

ATM money counter

380 of 687ost-k

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": ... }
VALUES = { "EUR" => [5, 10, 20, 50, 100, 200, 500], "USD" => ... }
const VALUES = { "EUR": [5, 10, 20, 50, 100, 200, 500], "USD": ... }
// Note: VALUES and its internal arrays are frozen, don't try to mutate them

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.
Regular Expressions
Mathematics
Fundamentals

Stats:

CreatedDec 7, 2015
PublishedDec 7, 2015
Warriors Trained2011
Total Skips89
Total Code Submissions5632
Total Times Completed687
Python Completions380
JavaScript Completions278
Ruby Completions48
Total Stars65
% of votes with a positive feedback rating90% of 190
Total "Very Satisfied" Votes162
Total "Somewhat Satisfied" Votes19
Total "Not Satisfied" Votes9
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • ost-k Avatar
  • anter69 Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • bdupau Avatar
  • saudiGuy Avatar
Ad