Hackerrank – Library Fine

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Read 2 lines and parse dates.
Substract actual year, month, day and expected year, month and day.
Compare values and calculate fee:
– if year difference is greater than 0 theb return 10000
– if year difference is equal to 0 and month difference greater than 0 then return 45 * month difference
– if if year difference is equal to 0 and month difference equals to 0 and day diff greater than 0 then return 15 * day diff
– otherwise return 0.

I created solution in 4 languages:

All solutions are also available on my GitHub.

Scala

Java

JavaScript

Ruby