aboutsummaryrefslogtreecommitdiff
path: root/challenge-059/mark-anderson/perl/ch-2.pl
blob: bdbaf4b42d65beb782ae8661057f915a6da6e22d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env perl

use Modern::Perl;
use Algorithm::Combinatorics 'combinations';

my @list = (2, 3, 4);

my $sum;

for my $ref (combinations(\@list, 2)) {
   $sum += sprintf("%b", $ref->[0] ^ $ref->[1]) =~ tr/1//;
}

say $sum;