From 4f8745c22e16c7923047f02c405f4a6bf0be1a5d Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 5 Dec 2024 09:39:07 +0100 Subject: Add 2024 day 5 solutions --- 2024/05/puzzle-1.awk | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 2024/05/puzzle-1.awk (limited to '2024/05/puzzle-1.awk') diff --git a/2024/05/puzzle-1.awk b/2024/05/puzzle-1.awk new file mode 100755 index 0000000..bd9ed68 --- /dev/null +++ b/2024/05/puzzle-1.awk @@ -0,0 +1,18 @@ +#!/usr/bin/awk -f + +BEGIN { FS = "[|,]" } + +/\|/ { rules[$1][$2] = 1 } +/,/ { + delete seen + for (i = 1; i <= NF; i++) { + for (j in seen) { + if (j in rules[$i]) + next + } + seen[$i] = 1 + } + mid += $(i / 2) +} + +END { print mid } \ No newline at end of file -- cgit v1.2.3