diff options
Diffstat (limited to 'advent-of-code/2022/04/1.c')
| -rw-r--r-- | advent-of-code/2022/04/1.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/advent-of-code/2022/04/1.c b/advent-of-code/2022/04/1.c new file mode 100644 index 0000000..3999003 --- /dev/null +++ b/advent-of-code/2022/04/1.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int main() { + FILE *fp = fopen("input", "r"); + int x1, x2, y1, y2; + int count = 0; + while (fscanf(fp, "%d-%d,%d-%d", &x1, &x2, &y1, &y2) != EOF) { + if (x1 <= y1 && x2 >= y2 || x1 >= y1 && x2 <= y2) { + count++; + } + } + printf("%d\n", count); + return 0; +} |
