"be consistent" | |
PerlMonks |
Re: Re: Re: amount permutationsby Limbic~Region (Chancellor) |
on Mar 04, 2004 at 20:01 UTC ( [id://334003]=note: print w/replies, xml ) | Need Help?? |
gr0k,
Well, it depends on what answer you want. To be honest you were checking the same number of combinations as me. The difference is you weren't counting ones that you discarded. There was effort spent on determing they could be discarded though - which is why I included all combinations. In order to make my $count look like your count will require more work - and make the process slower. If you want - you can change the position of $count++ to after the for loop. There you would only be counting the number of combinations that did not have a duplicate number in them and whose combined value was not greater than the target sum. I would recommend in the real problem removing all candidates that were already larger than the target number. Cheers - L~R
In Section
Seekers of Perl Wisdom
|
|