Skip to content

Instantly share code, notes, and snippets.

@quoll
Created January 1, 2016 17:40
Show Gist options
  • Save quoll/64e6bef3a84df8542aa0 to your computer and use it in GitHub Desktop.
Save quoll/64e6bef3a84df8542aa0 to your computer and use it in GitHub Desktop.
Euler31
(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