diff options
author | June McEnroe <june@causal.agency> | 2021-12-02 11:44:01 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-12-02 11:44:01 -0500 |
commit | b19d5feac5278f22a87eaf3fd77be4674e41e185 (patch) | |
tree | 702726bd751a431d7500ac1ce2395d57eaae433b /2021/day02.pl | |
parent | Solve day 1 part 2 (diff) | |
download | aoc-b19d5feac5278f22a87eaf3fd77be4674e41e185.tar.gz aoc-b19d5feac5278f22a87eaf3fd77be4674e41e185.zip |
Solve day 2 part 1
Diffstat (limited to '')
-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"; |