summary refs log tree commit diff homepage
path: root/2021
diff options
context:
space:
mode:
Diffstat (limited to '2021')
-rw-r--r--2021/day02.pl6
1 files changed, 6 insertions, 0 deletions
diff --git a/2021/day02.pl b/2021/day02.pl
index 66e423a..30dc1d1 100644
--- a/2021/day02.pl
+++ b/2021/day02.pl
@@ -1,13 +1,19 @@
 use strict;
 use warnings;
 my ($depth, $pos) = (0, 0);
+my ($depth2, $pos2, $aim) = (0, 0, 0);
 while (<>) {
 	if (/forward (\d+)/) {
 		$pos += $1;
+		$pos2 += $1;
+		$depth2 += $aim * $1;
 	} elsif (/down (\d+)/) {
 		$depth += $1;
+		$aim += $1;
 	} elsif (/up (\d+)/) {
 		$depth -= $1;
+		$aim -= $1;
 	}
 }
 print $depth * $pos, "\n";
+print $depth2 * $pos2, "\n";
file.am?h=3.3.3p1&id=3b4a10a68682f3b8590450c9be75a8ed4c7307c4&follow=1'>Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe