]> www.fi.muni.cz Git - aoc.git/blob - 2015/32.pl
Day 25: examining the input
[aoc.git] / 2015 / 32.pl
1 #!/usr/bin/perl -w
2
3 use v5.16;
4 use strict;
5
6 my %g = (
7 children => 3,
8 cats => 7,
9 samoyeds => 2,
10 pomeranians => 3,
11 akitas => 0,
12 vizslas => 0,
13 goldfish => 5,
14 trees => 3,
15 cars => 2,
16 perfumes => 1,
17 );
18
19
20 AUNT:
21 while (<>) {
22         my ($id, $rest) = /Sue (\d+): (.*)/;
23         my %vals = $rest =~ /(\w+): (\d+)/g;
24         for my $v (keys %vals) {
25                 if ($v eq 'pomeranians' || $v eq 'goldfish') {
26                         next AUNT if defined $g{$v} && $g{$v} <= $vals{$v};
27                 } elsif ($v eq 'cats' || $v eq 'trees') {
28                         next AUNT if defined $g{$v} && $g{$v} >= $vals{$v};
29                 } else {
30                         next AUNT if defined $g{$v} && $g{$v} != $vals{$v};
31                 }
32         }
33         say "aunt $id";
34 }