]> www.fi.muni.cz Git - aoc.git/blob - 2018/27.pl
Day 25: examining the input
[aoc.git] / 2018 / 27.pl
1 #!/usr/bin/perl -w
2
3 use v5.30;
4 use strict;
5
6 my $iters = shift @ARGV;
7 $iters += 10;
8
9 my @r = qw(3 7);
10 my @p = qw(0 1);
11
12 while (@r < $iters) {
13         my $n = $r[$p[0]] + $r[$p[1]];
14         push @r, split //, $n;
15         for (0 .. 1) {
16                 $p[$_] += 1 + $r[$p[$_]];
17                 $p[$_] -= @r while $p[$_] >= @r;
18         }
19         # say join ' ', @p, @r;
20 }
21
22 say join('', @r[-10 .. -1])
23