]> www.fi.muni.cz Git - aoc.git/blob - 2020/46re.pl
Day 25: examining the input
[aoc.git] / 2020 / 46re.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 my $rounds;
6 ($rounds, $_) = @ARGV;
7 $_ .= '3' x 10_000_000;
8
9 while ($rounds--) {
10         my ($cur) = /\A(.)/;
11         do {
12                 $cur--;
13                 $cur = 9 if $cur == 0;
14         } while (/\A.{1,3}$cur/);
15         
16         s/\A(.)(...)(.*)$cur(.*)\z/$3$cur$2$4$1/;
17         # print $_, "\n";
18 }
19
20 s/\A(.*)1(.*)\z/Result is $2$1\n/;
21 print;