aboutsummaryrefslogtreecommitdiff
path: root/challenge-059/jo-37/perl/ch-2.pl
blob: 85ead44c0dfd33cfd9bcb054f626483b5e987b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl

# expects input in @ARGV
# prints result to STDOUT
# numbers must be in the range 0 .. 2**64 - 1

use strict;
use warnings;
use List::Util qw(reduce);

my @bits = map {pack 'Q', $_} @ARGV;
my $sum;
while (defined (my $bits = shift @bits)) {
	$sum += unpack '%64b*', $bits ^ $_ foreach @bits;
}
print $sum, "\n";