Added day 4.

This commit is contained in:
Andrew Lalis 2022-12-04 06:20:48 +01:00
parent 8ba3d25b3d
commit 31463e7a81
3 changed files with 1024 additions and 0 deletions

1000
input/4.txt Normal file

File diff suppressed because it is too large Load Diff

12
src/s4a.d Normal file
View File

@ -0,0 +1,12 @@
module s4a;
import util;
void main() {
readText("input/4.txt").strip.splitter("\n")
.count!((line) {
int a, b, c, d;
formattedRead(line.strip, "%d-%d,%d-%d", a, b, c, d);
return (a >= c && b <= d) || (c >= a && d <= b);
})
.writeln;
}

12
src/s4b.d Normal file
View File

@ -0,0 +1,12 @@
module s4b;
import util;
void main() {
readText("input/4sample.txt").strip.splitter("\n")
.count!((line) {
int a, b, c, d;
formattedRead(line.strip, "%d-%d,%d-%d", a, b, c, d);
return (a <= d && c <= b);
})
.writeln;
}