summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--2022/day04.awk12
1 files changed, 12 insertions, 0 deletions
diff --git a/2022/day04.awk b/2022/day04.awk
new file mode 100644
index 0000000..78ff511
--- /dev/null
+++ b/2022/day04.awk
@@ -0,0 +1,12 @@
+BEGIN {
+	FS = "[-,]";
+}
+function contains(a, b, x, y) {
+	return x >= a && y <= b;
+}
+{
+	if (contains($1, $2, $3, $4) || contains($3, $4, $1, $2)) pairs++;
+}
+END {
+	print pairs;
+}
/a>June McEnroe 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe