Created
January 1, 2016 17:40
-
-
Save quoll/64e6bef3a84df8542aa0 to your computer and use it in GitHub Desktop.
Euler31
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
(def denoms [200 100 50 20 10 5 2 1]) | |
(def c (count denoms)) | |
(defn calc | |
"Return count for combinations, starting at the index for a given size denomination" | |
[ndx value] | |
(if (zero? value) | |
1 | |
(->> (range ndx c) | |
(map (fn [n] [n (- value (denoms n))])) | |
(drop-while #(> 0 (second %))) | |
(map #(apply calc %)) | |
(apply +)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment