]> www.fi.muni.cz Git - aoc.git/blob - 2016/14.pl
Year 2016, days 1-10: so far pretty interesting
[aoc.git] / 2016 / 14.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use v5.30;
5
6 my $count;
7
8 line:
9 while (<>) {
10         chomp;
11         my $super = $_;
12         $super =~ s/\[.*?\]/---/g;
13         my $hyper = join('---', ($_ =~ /\[([^\]]*)\]/g));
14         while ($super =~ /(\w)(?!\1)(\w)\1/g) {
15                 pos($super)-= 2;
16                 my $s = "$2$1$2";
17                 if ($hyper =~ /$s/) {
18                         $count++;
19                         next line;
20                 }
21         }
22 }
23
24 say $count;