Advent of Code 2025, done in C++

day[04]: using `size_t` for managing sizes

bpavuk.neocities.org e0355ea4 3cb7f065

verified
Changed files
+11 -10
src
+11 -10
src/04/solution.cxx
··· 1 #include <filesystem> 2 #include <fstream> 3 #include <print> ··· 17 } 18 }; 19 20 - unsigned long width() { return data[0].length(); } 21 22 - unsigned long height() { return data.size(); } 23 24 - std::string &operator[](unsigned long idx) { return data[idx]; } 25 26 - const std::string &operator[](unsigned long idx) const { return data[idx]; } 27 28 - std::string get_surrounding(unsigned long row, unsigned long col) { 29 std::string sur = ""; 30 sur.resize(8); 31 - unsigned long wid = width(); 32 auto hi = height(); 33 34 if (row > 0 && col > 0) { ··· 64 }; 65 66 struct Roll { 67 - unsigned long row; 68 - unsigned long col; 69 }; 70 71 std::vector<Roll> get_removable_rolls(Matrix &data) { 72 std::vector<Roll> rolls{}; 73 - for (unsigned long row = 0; row < data.height(); ++row) { 74 - for (unsigned long col = 0; col < data.width(); ++col) { 75 if (data[row][col] != '@') { 76 continue; 77 }
··· 1 + #include <cstddef> 2 #include <filesystem> 3 #include <fstream> 4 #include <print> ··· 18 } 19 }; 20 21 + std::size_t width() { return data[0].length(); } 22 23 + std::size_t height() { return data.size(); } 24 25 + std::string &operator[](std::size_t idx) { return data[idx]; } 26 27 + const std::string &operator[](std::size_t idx) const { return data[idx]; } 28 29 + std::string get_surrounding(std::size_t row, std::size_t col) { 30 std::string sur = ""; 31 sur.resize(8); 32 + std::size_t wid = width(); 33 auto hi = height(); 34 35 if (row > 0 && col > 0) { ··· 65 }; 66 67 struct Roll { 68 + std::size_t row; 69 + std::size_t col; 70 }; 71 72 std::vector<Roll> get_removable_rolls(Matrix &data) { 73 std::vector<Roll> rolls{}; 74 + for (std::size_t row = 0; row < data.height(); ++row) { 75 + for (std::size_t col = 0; col < data.width(); ++col) { 76 if (data[row][col] != '@') { 77 continue; 78 }