From 501ae2acc46f48854326c8d83979f9e28986f775 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Tue, 15 Dec 2020 01:34:38 -0500 Subject: [PATCH] Clean up day 15 --- day15/day15.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) 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);