]> www.fi.muni.cz Git - aoc.git/blob - 2016/30.pl
Day 25: examining the input
[aoc.git] / 2016 / 30.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use v5.30;
5
6 my @positions;
7 my @npos;
8 while (<>) {
9         my ($disc, $pos, $start) = /Disc #(\d+) has (\d+) p.* position (\d+)/;
10         $disc--;
11         $positions[$disc] = $start;
12         $npos[$disc] = $pos;
13 }
14
15 push @positions, 0;
16 push @npos, 11;
17
18 my $t = -1;
19 TIME:
20 while (1) {
21         $t++;
22         for my $d (0 .. $#positions) {
23                 next TIME if ($positions[$d] + $t + 1 + $d) % $npos[$d];
24         }
25         say "$t";
26         last;
27 }
28