Don't make unnecessary comparisons.
In the original implementation, you're making eight comparisons on each pair of characters when you only need two.
if (${$strings[$i]}[$k]) { if (${$strings[$j]}[$k]) { $c11++; } else { $c10++; } } else { if (${$strings[$j]}[$k]) { $c01++; } else { $c00++; } }
In reply to Re: Speeding permutation counting
by dsheroh
in thread Speeding permutation counting
by albert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |