Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Challenge: Number of unique ways to reach target sumby ambrus (Abbot) |
on Feb 15, 2006 at 14:18 UTC ( [id://530383]=note: print w/replies, xml ) | Need Help?? |
This can speed the calculation to Here's the resulting faster variant of my script: (Update: I've removed the redundant code from this snippet, as noted on Re: Challenge: Number of unique ways to reach target sum and updated the benchmarks accordingly) This of course works only in those solutions which calculate the number of possibilities only, not for those that iterate on them all. Update: blokhead's reply has another interesting optimization. Update: like blokhead does makes it even more faster (with 40%). Here's the newer code.Update: Improving this a tad bit more, we get
In Section
Seekers of Perl Wisdom
|
|