File tree Expand file tree Collapse file tree 4 files changed +13
-14
lines changed
Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ The solutions have been created in the C++ programming language as a library.
77| | ||||||
88| -| -| -| -| -| -| -|
99|| 1| 2| 3| 4| 5| 6|
10- || :x : | | :x : || | |
10+ || :x : | : x : | :x : || | |
1111| 7| 8| 9| 10| 11| 12| 13|
1212| | | | | | | | |
1313| 14| 15| 16| 17| 18| 19| 20|
Original file line number Diff line number Diff line change 1010#include < numeric>
1111#include < vector>
1212#include < algorithm>
13+ #include < iterator>
1314
1415#include " spdlog/spdlog.h"
1516
Original file line number Diff line number Diff line change @@ -10,5 +10,15 @@ int main(int argc, char** argv) {
1010 return 1 ;
1111 }
1212
13+ const std::filesystem::path input_file{argv[1 ]};
14+
15+ const std::vector<bool > report_safety = AdventOfCode24::Day2::check_reactor_safety (input_file, false );
16+ const std::vector<bool > report_safety_dampened = AdventOfCode24::Day2::check_reactor_safety (input_file, true );
17+ const int n_safe = std::count_if (report_safety.begin (), report_safety.end (), [](bool x){return x;});
18+ const int n_safe_dampened = std::count_if (report_safety_dampened.begin (), report_safety_dampened.end (), [](bool x){return x;});
19+
20+ spdlog::info (" For file '" + input_file.string () + " ' the number of safe reports is " + std::to_string (n_safe));
21+ spdlog::info (" With dampening the number is " + std::to_string (n_safe_dampened));
22+
1323 return 0 ;
1424}
Original file line number Diff line number Diff line change 11#include " advent_of_code/day_2.hxx"
2- #include " spdlog/spdlog.h"
3- #include < algorithm>
4- #include < cstdlib>
5- #include < iostream>
6- #include < iterator>
7- #include < optional>
8- #include < stdexcept>
9- #include < string>
2+
103
114namespace AdventOfCode24 ::Day2 {
125 std::vector<int > read_line (std::istringstream& line) {
@@ -75,11 +68,6 @@ namespace AdventOfCode24::Day2 {
7568 return false ;
7669 }
7770
78- for (auto & n : values) {
79- std::cout << n << " ," ;
80- }
81- std::cout << std::endl;
82-
8371 auto invalid_number_iter{check_numbers (values, general_trend)};
8472
8573 // If no results then line is valid
You can’t perform that action at this time.
0 commit comments