in reply to Speeding permutation counting
$count{$_}++ for $string =~ /../g;
Update: With the clarifications of the problem statement:
while( @strings ) { my( $x, $y )= splice @strings, 0, 2; my %count; while( $x =~ /(.)/g ) { my $x1= $1; $y =~ /(.)/g or die "..."; $count{ $x1.$1 }++; # Or replace all of the above with: #$count{ "$1" . ( $y =~ /(.)/g ? "$1" : '' ) }++; } print join " ", %count, $/; }
with the (simple) cleaning up of the output left as an excercise.
- tye
|
|---|