X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=12.pl;h=c8b97b9fb2ddbb507e61152e5eafe1f55655896b;hb=HEAD;hp=c24e26c57ca3ecd699290cb450f14d0747a97b10;hpb=9e2e08adc8d381ddc5387592de0dba72e391b2c9;p=aoc2020.git diff --git a/12.pl b/12.pl index c24e26c..c8b97b9 100755 --- a/12.pl +++ b/12.pl @@ -1,7 +1,6 @@ #!/usr/bin/perl -w use strict; -use Data::Dumper; local $/ = "\n\n"; @@ -10,12 +9,11 @@ my $sum = 0; while (<>) { my $nper = 0; my %q; - for my $per (split /\n/) { + for (split /\n/) { $nper++; - $q{$_}++ for grep { /\S/ } split(//, $per); + $q{$_}++ for split //; } - my $count = grep { $q{$_} == $nper } keys %q; - $sum += $count; + $sum += grep { $q{$_} == $nper } keys %q; } print "$sum\n";