]> www.fi.muni.cz Git - aoc.git/blobdiff - 2017/10.pl
AoC 2017 begins
[aoc.git] / 2017 / 10.pl
diff --git a/2017/10.pl b/2017/10.pl
new file mode 100755 (executable)
index 0000000..7aad6f1
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use v5.30;
+use strict;
+
+
+my $pc = 0;
+chomp (my @offs = <>);
+
+my $steps = 0;
+while ($pc >= 0 && $pc < @offs) {
+       # say "$steps $pc $offs[$pc]";
+       my $off = $offs[$pc];
+       if ($off >= 3) {
+               $offs[$pc]--;
+       } else {
+               $offs[$pc]++;
+       }
+       $pc += $off;
+       $steps++;
+}
+
+say $steps;