aboutsummaryrefslogtreecommitdiff
path: root/2025/11/puzzle-1.awk
diff options
context:
space:
mode:
authorThomas Voss <thomas.voss@humanwave.nl> 2025-12-11 10:58:18 +0100
committerThomas Voss <thomas.voss@humanwave.nl> 2025-12-11 10:58:18 +0100
commit40fc3368e8d70b8279158fed2547f0025a4f6aa9 (patch)
treedb63bd42206e1b8c18d91a0da4bbe547b51f03ef /2025/11/puzzle-1.awk
parentb4431851ea5b0a9b82c38e13fcbe0301d4a42e0d (diff)
Add 2025 day 11 solutions
Diffstat (limited to '2025/11/puzzle-1.awk')
-rwxr-xr-x2025/11/puzzle-1.awk20
1 files changed, 20 insertions, 0 deletions
diff --git a/2025/11/puzzle-1.awk b/2025/11/puzzle-1.awk
new file mode 100755
index 0000000..2969c24
--- /dev/null
+++ b/2025/11/puzzle-1.awk
@@ -0,0 +1,20 @@
+#!/usr/bin/gawk -f
+
+function npaths(src, dst, n, i)
+{
+ if (src == dst)
+ return 1;
+ n = 0
+ for (i in paths[src])
+ n += npaths(paths[src][i], dst)
+ return n
+}
+
+BEGIN { FS = ":? " }
+
+{
+ for (i = 2; i <= NF; i++)
+ paths[$1][i - 1] = $i
+}
+
+END { print npaths("you", "out") }