adventofcode/2015/16/1.pl
Yanick Champoux f6240e130f 2016-16
2017-12-11 11:49:26 -05:00

23 lines
411 B
Perl

use 5.20.0;
use List::AllUtils qw/ pairmap reduce pairs /;
my %target = (
children=> 3,
cats=> 7,
samoyeds=> 2,
pomeranians=> 3,
akitas=> 0,
vizslas=> 0,
goldfish=> 5,
trees=> 3,
cars=> 2,
perfumes=> 1,
);
while(<>) {
my %attr = eval( ( split ':', $_, 2 )[1] =~ s/:/=>/gr );
die $_ if reduce {
$a and $target{$b->[0]} == $b->[1]
} 1, pairs %attr;
}