aboutsummaryrefslogtreecommitdiff
path: root/2024/01/puzzle-2.awk
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-12-01 17:21:32 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-12-01 17:21:32 +0100
commit9ad233e4d967f7c134a1d6c50965bcdb722432ab (patch)
tree5e1807631bc41d2be760ceda8b8c0f23520003b5 /2024/01/puzzle-2.awk
parentfdba09c1c6c67c9081cf470cd6b3c4e8b7670cf6 (diff)
Add solutions for 2024 day 1
Diffstat (limited to '2024/01/puzzle-2.awk')
-rwxr-xr-x2024/01/puzzle-2.awk12
1 files changed, 12 insertions, 0 deletions
diff --git a/2024/01/puzzle-2.awk b/2024/01/puzzle-2.awk
new file mode 100755
index 0000000..8400a16
--- /dev/null
+++ b/2024/01/puzzle-2.awk
@@ -0,0 +1,12 @@
+#!/usr/bin/awk -f
+
+{
+ xs[++i] = $1
+ ys[$2]++
+}
+
+END {
+ for (i in xs)
+ d += xs[i] * ys[xs[i]]
+ print d
+} \ No newline at end of file