aboutsummaryrefslogtreecommitdiff
path: root/2021/02/puzzle-2.awk
diff options
context:
space:
mode:
Diffstat (limited to '2021/02/puzzle-2.awk')
-rwxr-xr-x2021/02/puzzle-2.awk6
1 files changed, 6 insertions, 0 deletions
diff --git a/2021/02/puzzle-2.awk b/2021/02/puzzle-2.awk
new file mode 100755
index 0000000..73fe23e
--- /dev/null
+++ b/2021/02/puzzle-2.awk
@@ -0,0 +1,6 @@
+#!/usr/bin/env -S awk -f
+
+/forward/ { hor += $2; ver += aim * $2 }
+/up/ { aim -= $2 }
+/down/ { aim += $2 }
+END { print hor * ver }