Skip to content

Instantly share code, notes, and snippets.

@abedra
Created November 27, 2012 02:22
Show Gist options
  • Save abedra/4151997 to your computer and use it in GitHub Desktop.
Save abedra/4151997 to your computer and use it in GitHub Desktop.
Coin Changer
(defn change [cents]
(loop [amount cents
change []]
(if (or (zero? amount) (> 0 amount))
change
(let [coins [25 10 5 1]
coin (apply max (filter (partial >= amount) coins))]
(recur (- amount coin) (conj change coin))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment