Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: fastest way to compare numerical strings?by Anonymous Monk |
on Jul 01, 2008 at 13:44 UTC ( [id://694946]=note: print w/replies, xml ) | Need Help?? |
Is there a reason why your inner loop starts $v at 0?
Your loop seems to start by comparing 0 to 0, then to 1, then to 2...When $n increments you compare 1 to 0, 1 to 1, etc. But aren't all the comparisons for $v <= $n ones that you've already done? There doesn't seem to be an obvious value to comparing 0 to 1, and then later comparing 1 to 0. They are, after all, both members of the same list. Could you change the inner loop to start with $v = $n + 1 and reduce the number of comparisons significantly?
In Section
Seekers of Perl Wisdom
|
|