Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- no warnings 'portable'; # oct being used on binary nubmer > 32-bits
- use feature qw(say);
- $/ = '';
- use constant KEY => 0;
- use constant LOCK => 1;
- my @items;
- foreach my $item (map {join('', map {y/.#/01/; $_} split /\n/)} <>) {
- push( $items[ substr($item, 0, 1) ]->@*, oct("0b$item") );
- }
- my $part1 = 0;
- foreach my $lock ($items[LOCK]->@*) {
- $part1 += grep {($_ & $lock) == 0} $items[KEY]->@*;
- }
- say "Part 1: $part1";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement