Finished day 4 aoc

This commit is contained in:
2022-12-08 13:17:28 +01:00
parent 06beea5300
commit 17c6bbeae8
3 changed files with 1033 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
ifstream input_file("input.txt");
string line;
unsigned int score = 0;
while(getline(input_file, line)){
stringstream ss(line);
int x, y, a, b;
char leftovers;
ss >> x >> leftovers >> y >> leftovers >> a >> leftovers >> b;
// cout << x << "-" << y << "," << a << "-" << b << endl;
if((x <= a && y >= a) || (a <= x && b >= x)){
score++;
}
}
cout << "Score: " << score << endl;
return 0;
}

View File

@@ -0,0 +1,6 @@
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8