Skip to content

Instantly share code, notes, and snippets.

@lbeschastny
Created November 27, 2014 23:05
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 lbeschastny/e1f16b4f888bbb532526 to your computer and use it in GitHub Desktop.
Save lbeschastny/e1f16b4f888bbb532526 to your computer and use it in GitHub Desktop.
(defn solve [coll n len]
(when-let [s (seq coll)]
(if (= len 1)
(map list (filter #{n} s))
(let [[h & ts] s]
(concat (map (partial cons h)
(solve ts (- n h) (dec len)))
(solve ts n len))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment