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");
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.