aboutsummaryrefslogtreecommitdiff
path: root/2024/01/puzzle-2.awk
diff options
context:
space:
mode:
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