summaryrefslogtreecommitdiff
path: root/2022/day04/main2.c
blob: d26bdb6b3ba8ce5b88890bf49a3bf70eaae94a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>

int main()
{
    int a1,a2,b1,b2;
    int overlaps = 0;
    while (scanf("%d-%d,%d-%d", &a1, &a2, &b1, &b2) != EOF)
    {
        // printf("%d-%d,%d-%d", a1, a2, b1, b2);
        if ( 
                ((a1 >= b1) && (a2 <= b2)) || ((b1 >= a1) && (b2 <= a2)) || 
                ((a1 <= b1) && (a2 >= b1) || (a1 <= b2) && (a2 >= b2) ) 
                ) {
            overlaps++;
        }
    }
    printf("%d\n", overlaps);
}