Skip to content

Instantly share code, notes, and snippets.

@uday-rayala
Created January 2, 2015 03:45
Show Gist options
  • Save uday-rayala/9bf6ddf3c3c8ad130469 to your computer and use it in GitHub Desktop.
Save uday-rayala/9bf6ddf3c3c8ad130469 to your computer and use it in GitHub Desktop.
(defn get-change [coins value]
(->> (tree-seq #(> value (reduce + %))
#(map (fn [c] (sort (conj % c))) coins)
[])
(filter #(= 10 (reduce + %)))
distinct))
(get-change [1 2 3] 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment