Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd dec 4 part 2 - aoc22 - advent of code 2022 solutions
git clone git://src.adamsgaard.dk/aoc22
Log
Files
Refs
README
---
commit 02e9cc5f5cf0456ab4a261952bc91906f392c448
parent 0bc85c36d6e35b7a76c5c9217cb56b82118736ec
Author: Anders Damsgaard <[email protected]>
Date: Sun, 4 Dec 2022 08:10:45 +0000
add dec 4 part 2
Diffstat:
A 4/aoc4b | 9 +++++++++
M 4/mkfile | 5 +++++
2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/4/aoc4b b/4/aoc4b
t@@ -0,0 +1,9 @@
+#!/bin/awk -f
+BEGIN{ FS="," }
+{
+ if (split($1, a, "-") != 2 || split($2, b, "-") != 2)
+ printf("split error: %s", $0)
+ if (a[1] <= b[2] && b[1] <= a[2])
+ sum++
+}
+END{ print sum }
diff --git a/4/mkfile b/4/mkfile
t@@ -1,7 +1,12 @@
run:V:
./aoc4 <input
+ ./aoc4b <input
test:V:
# correct result: 2
# pair 4 and 5 are fully contained
./aoc4 <testinput
+
+test2:V:
+ # correct result: 4
+ ./aoc4b <testinput
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.