diff options
Diffstat (limited to '2021/day02.pl')
-rw-r--r-- | 2021/day02.pl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/2021/day02.pl b/2021/day02.pl new file mode 100644 index 0000000..66e423a --- /dev/null +++ b/2021/day02.pl @@ -0,0 +1,13 @@ +use strict; +use warnings; +my ($depth, $pos) = (0, 0); +while (<>) { + if (/forward (\d+)/) { + $pos += $1; + } elsif (/down (\d+)/) { + $depth += $1; + } elsif (/up (\d+)/) { + $depth -= $1; + } +} +print $depth * $pos, "\n"; |