]> www.fi.muni.cz Git - aoc.git/blob - 2022/05.pl
a7e1f9db71bcd52fbef00ca118a04c726d97e9a8
[aoc.git] / 2022 / 05.pl
1 #!/usr/bin/perl -w
2
3 use v5.36;
4 use strict;
5 use experimental 'multidimensional';
6
7 my $sum;
8 while (<>) {
9         chomp;
10         substr($_, length()/2, 0) = ' ';
11         my ($c) = /(.)\S*\s\S*\1/;
12         $sum += $c =~ /[A-Z]/
13                 ? ord($c) - ord('A') + 27
14                 : ord($c) - ord('a') + 1; 
15 }
16 say $sum;