Last active
August 29, 2015 13:56
-
-
Save apaleslimghost/9206896 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
fit = (coins, amt)--> | |
maximum filter (<= amt), coins | |
fit-sterling = fit [1 2 5 10 20 50 100 200] | |
change = (fit, amt)--> | |
| amt is 0 => [] | |
| otherwise => let coin = fit amt | |
[coin] ++ change fit, (amt - coin) | |
names = | |
1: 'penny' | |
2: 'tuppence' | |
5: 'fivepence' | |
10: 'ten pence' | |
20: 'twenty pence' | |
50: 'fifty pence' | |
100: 'quid' | |
200: 'two quid' | |
count-by (names.), change fit-sterling, 16564 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment