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(sum);
- $/ = '';
- my @valid;
- $_ = <>; # read ranges:
- foreach my $range (map { s#-#..#r } m#\d+-\d+#g) {
- $valid[ $_ ] = 1 foreach (eval( $range ));
- }
- $_ = <>; # skip my ticket
- $_ = <>; # check nearby tickets:
- print "Part 1: ", sum( grep { !$valid[$_] } (m#\d+#g) ), "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement