]> www.fi.muni.cz Git - aoc.git/blobdiff - 2016/14.pl
Year 2016, days 1-10: so far pretty interesting
[aoc.git] / 2016 / 14.pl
diff --git a/2016/14.pl b/2016/14.pl
new file mode 100755 (executable)
index 0000000..4694715
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use strict;
+use v5.30;
+
+my $count;
+
+line:
+while (<>) {
+       chomp;
+       my $super = $_;
+       $super =~ s/\[.*?\]/---/g;
+       my $hyper = join('---', ($_ =~ /\[([^\]]*)\]/g));
+       while ($super =~ /(\w)(?!\1)(\w)\1/g) {
+               pos($super)-= 2;
+               my $s = "$2$1$2";
+               if ($hyper =~ /$s/) {
+                       $count++;
+                       next line;
+               }
+       }
+}
+
+say $count;