Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active August 29, 2015 13:56
Show Gist options
  • Save apaleslimghost/9206896 to your computer and use it in GitHub Desktop.
Save apaleslimghost/9206896 to your computer and use it in GitHub Desktop.
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