|No such thing as a small change|
Better algorithm than brute-force stack for combinatorial problems?by Solo (Deacon)
|on May 21, 2004 at 20:22 UTC||Need Help??|
Solo has asked for the
wisdom of the Perl Monks concerning the following question:
I'm using a stack algorithm to solve a combinatorial problem--and I'm out of my comfort zone. This simplified example finds the subsets of a set of integers whos sum is a target number.
Searches on 'perl perl stack' or 'perl perl subset' proved rather off-topic, and 'combinatorial algorithm' was way out there. So I'm hoping for some constructive criticism here. For starters, is there a better/faster than brute-force algorithm? Or how about a more Perlish implementation? I feel like a C programmer ;p
Here's the code I'm using now.
Update: fixed a small code typo