summaryrefslogtreecommitdiff
path: root/2022/day04/main.c
diff options
context:
space:
mode:
Diffstat (limited to '2022/day04/main.c')
-rw-r--r--2022/day04/main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/2022/day04/main.c b/2022/day04/main.c
new file mode 100644
index 0000000..8233265
--- /dev/null
+++ b/2022/day04/main.c
@@ -0,0 +1,15 @@
+#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))) {
+ overlaps++;
+ }
+ }
+ printf("%d\n", overlaps);
+}