adventofcode/2020/04/part1.pm
2021-12-05 11:51:21 -05:00

26 lines
448 B
Perl

use 5.20.0;
use warnings;
use Path::Tiny;
use List::AllUtils qw/all/;
use parent qw/ Exporter/;
use experimental qw/
signatures
postderef
/;
our @EXPORT = qw/ valid_passports /;
sub valid_passports($file) {
my $data = path($file)->slurp;
my @passports = map { +{ split /:| |\n/ } } split "\n\n", $data;
return scalar grep {
my $p = $_;
all { $p->{$_} } qw/ byr iyr eyr hgt hcl ecl pid /
} @passports;
}