Created
November 27, 2014 23:05
-
-
Save lbeschastny/e1f16b4f888bbb532526 to your computer and use it in GitHub Desktop.
Refactored http://stackoverflow.com/a/27179390/1202461
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
(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