Created
March 25, 2015 05:54
-
-
Save AyaMorisawa/47f1da07e87e2ccdb009 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Money -> Number | |
money-sum = (money) -> money |> obj-to-pairs |> map apply (*) |> sum | |
# Number -> Money | |
to-money = (sum) -> | |
sum-places = "0000#sum" |> chars |> reverse |> map parse-int | |
10000: floor sum / 10000 | |
5000: if sum-places.3 >= 5 then 1 else 0 | |
1000: if sum-places.3 >= 5 then sum-places.3 - 5 else sum-places.3 | |
500: if sum-places.2 >= 5 then 1 else 0 | |
100: if sum-places.2 >= 5 then sum-places.2 - 5 else sum-places.2 | |
50: if sum-places.1 >= 5 then 1 else 0 | |
10: if sum-places.1 >= 5 then sum-places.1 - 5 else sum-places.1 | |
5: if sum-places.1 >= 5 then 1 else 0 | |
1: if sum-places.0 >= 5 then sum-places.0 - 5 else sum-places.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment