diff options
Diffstat (limited to '2023/02/src/part2.cpp')
-rw-r--r-- | 2023/02/src/part2.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/2023/02/src/part2.cpp b/2023/02/src/part2.cpp new file mode 100644 index 0000000..52b8fc8 --- /dev/null +++ b/2023/02/src/part2.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <algorithm> | ||
2 | #include <iostream> | ||
3 | #include <fstream> | ||
4 | |||
5 | #include "game.h" | ||
6 | |||
7 | int main(void) | ||
8 | { | ||
9 | int answer{}; | ||
10 | std::vector<Game> games{}; | ||
11 | |||
12 | std::ifstream input{ "resources/input.txt" }; | ||
13 | if (input.is_open()) | ||
14 | { | ||
15 | std::string line; | ||
16 | |||
17 | while (not std::getline(input,line).eof()) | ||
18 | { | ||
19 | games.push_back(Game::from_string(line)); | ||
20 | } | ||
21 | } | ||
22 | input.close(); | ||
23 | |||
24 | for (const auto& game : games) | ||
25 | { | ||
26 | answer += game.power(); | ||
27 | } | ||
28 | |||
29 | std::cout << answer << std::endl; | ||
30 | return 0; | ||
31 | } | ||