From 33ffff7af25f21343aaeba2a0786fa3a633b600a Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 4 Dec 2022 18:35:48 -0500 Subject: Solve day 4 part 1 --- 2022/day04.awk | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 2022/day04.awk 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; +} -- cgit 1.4.1