Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Recursion problem (Power set)by lodin (Hermit) |
on May 25, 2008 at 11:02 UTC ( [id://688394]=note: print w/replies, xml ) | Need Help?? |
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.) 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
In Section
Seekers of Perl Wisdom
|
|