]> www.fi.muni.cz Git - aoc.git/blob - 2023/15.pl
Day 8: more polished but still incorrect solution
[aoc.git] / 2023 / 15.pl
1 #!/usr/bin/perl -w
2
3 use v5.38;
4
5 chomp(my $steps = <>);
6 my @steps = split //, $steps;
7
8 scalar <>;
9
10 my %dirs;
11 while (<>) {
12         my @x = /\w{3}/g;
13         $dirs{$x[0].'L'} = $x[1];
14         $dirs{$x[0].'R'} = $x[2];
15 }
16
17 my $now = 'AAA';
18 my $i = 0;
19 while ($now ne 'ZZZ') {
20         $now = $dirs{$now . ($steps[$i++ % @steps])};
21 }
22 say $i;