diff --git a/day15/day15.cpp b/day15/day15.cpp index 512427f..51b4898 100644 --- a/day15/day15.cpp +++ b/day15/day15.cpp @@ -1,19 +1,11 @@ #include -#include -#include #include #include #include -#include -#include -#include +#include #include -constexpr char IGNORE_CHAR = 'X'; -constexpr auto MASK_PATTERN = R"(mask = ([X0-9]+))"; -constexpr auto MEM_PATTERN = R"(mem\[(\d+)\] = (\d+))"; - std::vector readInput(const std::string &filename) { std::vector input; std::string line; @@ -38,7 +30,7 @@ std::vector parseStartingNumbers(const std::vector &input) { return startingNumbers; } -int solve(const std::vector &startingNumbers, int max_n) { +int solve(const std::vector &startingNumbers, int num_turns) { std::unordered_map turnSpoken; int lastNumber = startingNumbers.back(); // Skip past the starting numbers< put them at the proper place @@ -47,7 +39,7 @@ int solve(const std::vector &startingNumbers, int max_n) { } // Keep passing on until the right n - for (int turn = startingNumbers.size() + 1; turn <= max_n; turn++) { + for (int turn = startingNumbers.size() + 1; turn <= num_turns; turn++) { int number = 0; if (turnSpoken.find(lastNumber) != turnSpoken.end()) { number = (turn - 1) - turnSpoken.at(lastNumber);