summary refs log tree commit diff homepage
path: root/2022
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-12-04 18:35:48 -0500
committerJune McEnroe <june@causal.agency>2022-12-04 18:35:48 -0500
commit33ffff7af25f21343aaeba2a0786fa3a633b600a (patch)
tree51cce72cd36f8a1c5f937ef9cd85bbe9191ac4cd /2022
parentSolve day 3 part 2 (diff)
downloadaoc-33ffff7af25f21343aaeba2a0786fa3a633b600a.tar.gz
aoc-33ffff7af25f21343aaeba2a0786fa3a633b600a.zip
Solve day 4 part 1
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;
+}