diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-12-04 17:36:44 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-12-04 17:36:44 +0200 |
| commit | 616af4d6944d9c6436e36ab1ef38238819ccea64 (patch) | |
| tree | 25247c469f2a5b7ebab584c47def25fa2cd07814 /2022/Day4/main.cpp | |
| parent | b6581928ca05708bc8aa1cc1c2b6ab44e7100a1a (diff) | |
| download | aoc-616af4d6944d9c6436e36ab1ef38238819ccea64.tar.xz aoc-616af4d6944d9c6436e36ab1ef38238819ccea64.zip | |
Added Rust solution for day3 and day4
Diffstat (limited to '2022/Day4/main.cpp')
| -rw-r--r-- | 2022/Day4/main.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/2022/Day4/main.cpp b/2022/Day4/main.cpp deleted file mode 100644 index b511da8..0000000 --- a/2022/Day4/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include<bits/stdc++.h> -using namespace std; - -struct P2 { - int start; - int end; -}; - -void solve_part_one() { - P2 first, second; - int ans = 0; - while(cin >> first.start >> first.end >> second.start >> second.end) { - if ((first.start >= second.start && first.end <= second.end) || (second.start >= first.start && second.end <= first.end)) { - ans++; - } - } - cout << ans << '\n'; -} - -void solve_part_two() { - P2 f, s; - int ans = 0; - while(cin >> f.start >> f.end >> s.start >> s.end) { - vector<int> vis(100, 0); - for (int i = f.start; i <= f.end; i++) { - vis[i] += 1; - } - for (int i = s.start; i <= s.end; i++) { - vis[i] += 1; - } - for (int i = 0; i <= vis.size(); i++) { - if(vis[i] == 2) { - ans++; - break; - } - } - } - cout << ans << '\n'; -} - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - // solve_part_one(); - solve_part_two(); -} - - |
