X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=15.pl;h=19d53b85b9cf9f2254b0f7e39b94e4b2ae146b60;hb=7135582c996b3dbc5fc402180c9cd58e5ccbbcce;hp=8a104b49af0f1fb1facde59e9dc28d04dde07377;hpb=bdaf9066de9b215aa44cb171f1ac6523e41b7af3;p=aoc2021.git diff --git a/15.pl b/15.pl index 8a104b4..19d53b8 100755 --- a/15.pl +++ b/15.pl @@ -2,11 +2,12 @@ use v5.16; +my %l = map { $_ => 1 } qw(2 3 4 7); my $sum; while (<>) { chomp; s/.*\| //; - $sum += grep { my $x = length; $x == 2 || $x == 3 || $x == 4 || $x == 7; } split /\s+/; + $sum += grep { $l{length()} } split /\s+/; } say $sum;