]> www.fi.muni.cz Git - aoc.git/blob - 2016/08.pl
Year 2016, days 1-10: so far pretty interesting
[aoc.git] / 2016 / 08.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use v5.30;
5
6 my $sum;
7 while (<>) {
8         chomp;
9         my ($code, $id, $csum) = /\A([a-z-]+)-(\d+)\[([a-z]{5})\]/;
10         my $d;
11         $code =~ s/-/ /g;
12         for (split //, $code) {
13                 if ($_ eq ' ') {
14                         $d .= ' ';
15                         next;
16                 }
17                 $d .= chr(ord('a') + ((ord($_)-ord('a')+$id) % 26));
18         }
19         say $id if $d =~ /pole/;
20 }