aboutsummaryrefslogtreecommitdiff
path: root/2018/01/puzzle-2.awk
diff options
context:
space:
mode:
authorThomas Voss <thomas.voss@humanwave.nl> 2025-12-10 16:21:25 +0100
committerThomas Voss <thomas.voss@humanwave.nl> 2025-12-10 16:21:25 +0100
commit73872ba08420a1f679e767b7bc68ed404d099c77 (patch)
tree1b401c75b897916f380eb7a3a36f028f59f62dd4 /2018/01/puzzle-2.awk
parent7ac240e75434d2bb47adfa50dad4f869a9b955ef (diff)
Add 2018 day 1 solutions
Diffstat (limited to '2018/01/puzzle-2.awk')
-rwxr-xr-x2018/01/puzzle-2.awk14
1 files changed, 14 insertions, 0 deletions
diff --git a/2018/01/puzzle-2.awk b/2018/01/puzzle-2.awk
new file mode 100755
index 0000000..2236499
--- /dev/null
+++ b/2018/01/puzzle-2.awk
@@ -0,0 +1,14 @@
+#!/usr/bin/awk -f
+
+{ xs[NR] = $1 }
+
+END {
+ for (;;) {
+ for (i = 1; i <= length(xs); i++) {
+ if (ys[x += xs[i]]++) {
+ print x
+ exit
+ }
+ }
+ }
+}