Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use List::AllUtils qw(pairwise);
- my @counts = (0) x 12;
- while (<>) {
- chomp;
- @counts = pairwise {$a + $b} @counts, @{[split //]};
- }
- my $half = $. / 2;
- my $gamma = oct("0b" . join( '', map {int($_ > $half)} @counts ));
- print "Part 1: ", $gamma * ($gamma ^ 0xFFF), "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement