]> www.fi.muni.cz Git - aoc.git/blob - 2017/10.pl
Day 25: examining the input
[aoc.git] / 2017 / 10.pl
1 #!/usr/bin/perl
2
3 use v5.30;
4 use strict;
5
6
7 my $pc = 0;
8 chomp (my @offs = <>);
9
10 my $steps = 0;
11 while ($pc >= 0 && $pc < @offs) {
12         # say "$steps $pc $offs[$pc]";
13         my $off = $offs[$pc];
14         if ($off >= 3) {
15                 $offs[$pc]--;
16         } else {
17                 $offs[$pc]++;
18         }
19         $pc += $off;
20         $steps++;
21 }
22
23 say $steps;