http://qs321.pair.com?node_id=688394


in reply to Recursion problem

This problem can be expressed mathematically as

s = { sum(y) = n | y in P(x) }
where x is the bag (list) of elements, n is the number the elements in the bag should sum up to, P is the "power bag" operator, and s is the set of solutions. (Bags allow duplicate elements, in sets all elements are unique.)

That is, all you need to figure out is how to write a "power bag" function, and luckily for you several people have done that already. Try searching CPAN for "power set" for Perl versions.

lodin

Replies are listed 'Best First'.
Re^2: Recursion problem (Power set)
by Anonymous Monk on May 25, 2008 at 11:26 UTC