]> www.fi.muni.cz Git - aoc.git/blob - 2017/33.pl
Day 25: examining the input
[aoc.git] / 2017 / 33.pl
1 #!/usr/bin/perl
2
3 use v5.30;
4 use strict;
5
6 my $in = 345;
7
8 my @buffer = (0);
9 my $pos = 0;
10 for (1 .. 2017) {
11         # say "$_ $pos ", join(',', @buffer);
12         $pos += $in;
13         if (@buffer > 1) {
14                 $pos %= scalar @buffer;
15         } else {
16                 $pos = 0;
17         }
18         $pos++;
19         splice @buffer, $pos, 0, $_;
20 }
21
22 say $buffer[$pos+1];
23