Advent of Code 2025, done in C++

day[07]: some improvements to formatting; formatted common library

bpavuk.neocities.org 85b2d70d 640d9fdf

verified
Changed files
+16 -13
src
+2
.clang-format
··· 1 1 BasedOnStyle: Google 2 2 AlignConsecutiveDeclarations: true 3 + AlignConsecutiveAssignments: true 4 + AlignConsecutiveMacros: true 3 5 BinPackParameters: false 4 6 ColumnLimit: 80 5 7 IndentWidth: 4
+4 -4
src/07/solution.cxx
··· 15 15 16 16 for (size_t i = 1; i < data.size(); ++i) { 17 17 auto& previous = data[i - 1]; 18 - auto& current = data[i]; 18 + auto& current = data[i]; 19 19 20 20 for (size_t ch = 0; ch < current.size(); ++ch) { 21 21 char previous_ch = previous[ch]; 22 - char current_ch = current[ch]; 22 + char current_ch = current[ch]; 23 23 if (previous_ch != 'S' && previous_ch != '|') { 24 24 continue; 25 25 } ··· 48 48 49 49 for (size_t i = 1; i < data.size(); ++i) { 50 50 auto& previous = data[i - 1]; 51 - auto& current = data[i]; 51 + auto& current = data[i]; 52 52 53 53 for (size_t ch = 0; ch < current.size(); ++ch) { 54 54 if (previous[ch] == '|' && current[ch] == '^') { ··· 87 87 result = count_possible_paths(data, new_pos, cache); 88 88 89 89 } else if (data[position.y][position.x] == '^') { 90 - Position left = Position{.x = position.x - 1, .y = position.y}; 90 + Position left = Position{.x = position.x - 1, .y = position.y}; 91 91 Position right = Position{.x = position.x + 1, .y = position.y}; 92 92 93 93 // a weird workaround to satisfy some static checks. maps must
+5 -4
src/common/getinputpath.cxx
··· 1 + #include <filesystem> 2 + 1 3 #include "common/istest.h" 2 - #include <filesystem> 3 4 4 5 const std::filesystem::path get_input_path(std::filesystem::path data_root) { 5 - std::filesystem::path data_path = 6 - data_root / (is_test() ? "test.txt" : "input.txt"); 6 + std::filesystem::path data_path = 7 + data_root / (is_test() ? "test.txt" : "input.txt"); 7 8 8 - return data_path; 9 + return data_path; 9 10 }
+5 -5
src/common/istest.cxx
··· 2 2 #include <string_view> 3 3 4 4 bool is_test() { 5 - std::string_view mode = "real"; 6 - if (const char *env_mode = std::getenv("AOC_MODE")) { 7 - mode = env_mode; 8 - } 5 + std::string_view mode = "real"; 6 + if (const char* env_mode = std::getenv("AOC_MODE")) { 7 + mode = env_mode; 8 + } 9 9 10 - return mode == "test"; 10 + return mode == "test"; 11 11 }