in reply to Speeding permutation counting
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++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Speeding permutation counting
by ikegami (Patriarch) on Jul 18, 2007 at 16:20 UTC | |
by dsheroh (Monsignor) on Jul 18, 2007 at 18:38 UTC |