Skip to content

Instantly share code, notes, and snippets.

@sritchie
Forked from gfredericks/money.clj
Created July 10, 2011 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/1074659 to your computer and use it in GitHub Desktop.
Save sritchie/1074659 to your computer and use it in GitHub Desktop.
mdeboard
(reduce
(fn [[amount-left coins] denom]
(let [{:keys [mod dividend]} (calc-coins amount-left denom)]
(if (pos? dividend)
[mod (assoc coins denom dividend)]
[amount-left coins])))
[amount {}]
denoms)
(fn [[amount {}] 20]
(let [{:keys [mod dividend]} (calc-coins amount-left denom)]
(if (pos? dividend)
[mod (assoc coins denom dividend)]
[amount-left coins])))
(let [{:keys [mod dividend]} (calc-coins 100 20)]
(if (pos? dividend)
[mod (assoc {} 20 dividend)]
[100 {}]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment