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