aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2022/04/2.c
blob: 5d30d1c6202460584bc3f4833f0cc5cefd2b5c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 && x1 <= y2 || x2 >= y1 && x2 <= y2 || x1 <= y1 && x2 >= y2) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}