Skip to content

Instantly share code, notes, and snippets.

@Ariarule
Created November 11, 2013 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ariarule/7406146 to your computer and use it in GitHub Desktop.
Save Ariarule/7406146 to your computer and use it in GitHub Desktop.
;; ariarule's solution to Generating k-combinations
;; https://4clojure.com/problem/103
(fn [n z]
(set (filter #(= (count %) n)
(reduce (fn [seqs b]
(mapcat
(fn [s] (#(map (partial conj %) z) s)) seqs)) [#{}] (range n)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment