diff options
author | Federico Igne <undyamon@disroot.org> | 2023-12-03 18:57:02 +0100 |
---|---|---|
committer | Federico Igne <undyamon@disroot.org> | 2023-12-03 18:57:02 +0100 |
commit | baaa6cd61c302c80c664e9aaa5e4ab2ab157b5cf (patch) | |
tree | 7d4d90f06b3f005f1dace2acf9ce154b22ed0e37 /2023/02/src/part2.cpp | |
parent | 109f2eff37a72d844ad785f7bd2b9dc7d01353b6 (diff) | |
download | aoc-baaa6cd61c302c80c664e9aaa5e4ab2ab157b5cf.tar.gz aoc-baaa6cd61c302c80c664e9aaa5e4ab2ab157b5cf.zip |
aoc(2302): Cube Conundrum
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 | } | ||