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 | c2de1081fd0aeb46d22c5d6b9f71bbb28a3fbc72 (patch) | |
| tree | 8e67168124684d20eda44b29685b39ebef741f0e /2021 | |
| parent | Solve day 1 part 2 (diff) | |
| download | aoc-c2de1081fd0aeb46d22c5d6b9f71bbb28a3fbc72.tar.gz aoc-c2de1081fd0aeb46d22c5d6b9f71bbb28a3fbc72.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"; |