X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=2022%2F06.pl;h=39b07aefabaa8a95607ed36ff2857ced034b2a94;hb=8f3c16911ba539432cb87c7329dedc821cab30da;hp=84ea0fbe44a073f51e7525f4c514ca08bd73f124;hpb=ceaf4a9778015b8d3779160af22ebc2ca686a320;p=aoc.git diff --git a/2022/06.pl b/2022/06.pl index 84ea0fb..39b07ae 100755 --- a/2022/06.pl +++ b/2022/06.pl @@ -11,9 +11,9 @@ while (<>) { next if $. % 3; $_ = $s; $s = ''; - my ($c) = /(.)\S*\s\S*\1\S*\s\S*\1/; - $sum += $c =~ /[A-Z]/ - ? ord($c) - ord('A') + 27 - : ord($c) - ord('a') + 1; + s/\A\S*(.)\S*\s\S*\1\S*\s\S*\1\S*\s?\z/$1/; + $sum += /[A-Z]/ + ? ord() - ord('A') + 27 + : ord() - ord('a') + 1; } say $sum;