Skip to content

Instantly share code, notes, and snippets.

@fupfin
Created December 29, 2014 03:39
Show Gist options
  • Save fupfin/b38ef7b59823b52899c2 to your computer and use it in GitHub Desktop.
Save fupfin/b38ef7b59823b52899c2 to your computer and use it in GitHub Desktop.
(defn count-change-for-us [amount] (count-change amount [1 5 10 25 50]))
(defn count-change [amount coins]
(cond (= amount 0) 1
(< amount 0) 0
(empty? coins) 0
:else (+ (count-change (- amount (first coins)) coins)
(count-change amount (rest coins)))
))
@fupfin
Copy link
Author

fupfin commented Dec 29, 2014

user=> (count-change-for-us 100)
292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment