]> www.fi.muni.cz Git - aoc2021.git/blob - 04.pl
Day 25: pretty straightforward
[aoc2021.git] / 04.pl
1 #!/usr/bin/perl -w
2
3 use v5.16;
4
5 my ($x, $z, $aim) = (0, 0, 0);
6 while (<>) {
7         my ($dir, $num) = split /\s+/;
8         if ($dir eq 'forward') {
9                 $x += $num;
10                 $z += $aim*$num;
11         }
12         $aim+=$num if $dir eq 'down';
13         $aim-=$num if $dir eq 'up';
14 }
15 say $x*$z;
16