Created
December 29, 2014 03:39
-
-
Save fupfin/b38ef7b59823b52899c2 to your computer and use it in GitHub Desktop.
This file contains 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
(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))) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
user=> (count-change-for-us 100)
292