in reply to Recursion problem
This problem can be expressed mathematically as
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.)s = { sum(y) = n | y in P(x) }
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 |
In Section
Seekers of Perl Wisdom