summary refs log tree commit diff homepage
path: root/2022/day04.awk
diff options
context:
space:
mode:
Diffstat (limited to '')
-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;
+}