Subset sums
Write a function that takes a set of numbers and returns all subsets that sum to a given number. That's a mouthful. Here's an example.
;; subsets that sum to 6
(subset-sums #{1 2 3 4 5} 6) ;=> #{ #{1 5} #{2 4} }
;; subsets that sum to 7
(subset-sums #{1 2 3 5 6 7} 7) ;=> #{ #{1 6} #{2 5} #{7} }
;; subsets that sum to 0
(subset-sums #{0 1 -1} 0) ;=> #{ #{} #{0} #{1 -1} #{0 1 -1} }
Thanks to this site for the challenge idea.
Here's my variation on Eric Normand's solution. It gains performance by using seqs for the intermediate subsets and deferring the creation of sets until needed.