in reply to Speeding permutation counting

use strict; use warnings; my @strings = qw/ 111011001010011110100010100001 111010000010010110000010000001 000101011100001000110101110000 000101111101001001111101111110 111011001010111110100010100001 000100010100000000010001010000 /; s/(?<=.)/\0/g for my @strings1 = @strings; # "abc" => "a\0b\0c\0" s/(?=.)/\0/g for my @strings2 = @strings; # "abc" => "\0a\0b\0c" for my $i (0..$#strings) { for my $j ($i+1..$#strings) { my %c; ++$c{$_} for ($strings1[$i] | $strings2[$j]) =~ /../g; print(join("\t", $i, $j, $c{'00'}||0, $c{'01'}||0, $c{'10'}||0, +$c{'11'}||0), "\n"); } }

Replies are listed 'Best First'.
Re^2: Speeding permutation counting
by ikegami (Patriarch) on Jul 18, 2007 at 16:55 UTC

    Nevermind. It was an interesting idea, but it sucks.

    Rate ikegami albert browseruk ikegami 5.76/s -- -26% -89% albert 7.84/s 36% -- -86% browseruk 54.8/s 851% 599% --

    Both ikegami and albert's version will be faster per string when processing 1000 strings instead of 100 (since they both have a big overhead), but not enough to even approach BrowserUk's version.

    Benchmark code: