Added sub folders for common, extra, and framework code files

This commit is contained in:
Stefan Müller 2025-04-30 20:37:03 +02:00
parent 08a94ba068
commit 01c300dce1
75 changed files with 103 additions and 103 deletions

View File

@ -30,13 +30,13 @@ Here, we have a few conditionals to determine on the fly which of the numbers wo
:mag_right: Puzzle: <https://adventofcode.com/2024/day/3>, :white_check_mark: Solver: [`MullItOver.cpp`](src/MullItOver.cpp)
A simple [finite state machine](include/aoc/StringStateMachine.hpp) crawling along the input character by character solves both parts nicely. The algorithm tracks whether `mul` instructions are enabled or not, but ignores this setting for part 1.
A simple [finite state machine](include/aoc/common/StringStateMachine.hpp) crawling along the input character by character solves both parts nicely. The algorithm tracks whether `mul` instructions are enabled or not, but ignores this setting for part 1.
### Day 4: Ceres Search
:mag_right: Puzzle: <https://adventofcode.com/2024/day/4>, :white_check_mark: Solver: [`CeresSearch.cpp`](src/CeresSearch.cpp)
For this puzzle I added a class for [points in two-dimensional space](include/aoc/Point2.hpp), so I can use these for simplifying directional computations. With that, the algorithm looks for all `X` and `A` for part 1 and 2, respectively, and tries to find the remaining characters, starting from that `X` or `A`.
For this puzzle I added a class for [points in two-dimensional space](include/aoc/common/Point2.hpp), so I can use these for simplifying directional computations. With that, the algorithm looks for all `X` and `A` for part 1 and 2, respectively, and tries to find the remaining characters, starting from that `X` or `A`.
### Day 5: Print Queue

View File

@ -17,7 +17,7 @@
#include <vector>
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
class BridgeRepair
: public Solver

View File

@ -17,7 +17,7 @@
#include <vector>
#include <aoc/LinesSolver.hpp>
#include <aoc/framework/LinesSolver.hpp>
class CeresSearch
: public LinesSolver

View File

@ -15,8 +15,8 @@
#pragma once
#include <aoc/Solver.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/Solver.hpp>
class ClawContraption
: public Solver

View File

@ -18,8 +18,8 @@
#include <array>
#include <vector>
#include <aoc/Interval.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Interval.hpp>
#include <aoc/framework/Solver.hpp>
class DiskFragmenter
: public Solver

View File

@ -17,9 +17,9 @@
#include <stack>
#include <aoc/Grid.hpp>
#include <aoc/LinesSolver.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Grid.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/LinesSolver.hpp>
class GardenGroups
: public LinesSolver

View File

@ -18,9 +18,9 @@
#include <bitset>
#include <vector>
#include <aoc/Grid.hpp>
#include <aoc/LinesSolver.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Grid.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/LinesSolver.hpp>
class GuardGallivant
: public LinesSolver

View File

@ -17,7 +17,7 @@
#include <set>
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
class HistorianHysteria
: public Solver

View File

@ -17,8 +17,8 @@
#include <vector>
#include <aoc/LinesSolver.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/LinesSolver.hpp>
class HoofIt
: public LinesSolver

View File

@ -15,8 +15,8 @@
#pragma once
#include <aoc/Graph.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Graph.hpp>
#include <aoc/framework/Solver.hpp>
class LanParty : public Solver
{

View File

@ -15,9 +15,9 @@
#pragma once
#include <aoc/MullData.hpp>
#include <aoc/MullStates.hpp>
#include <aoc/Solver.hpp>
#include <aoc/extra/MullData.hpp>
#include <aoc/extra/MullStates.hpp>
#include <aoc/framework/Solver.hpp>
class MullItOver
: public Solver

View File

@ -18,7 +18,7 @@
#include <map>
#include <vector>
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
class PlutonianPebbles : public Solver
{

View File

@ -17,8 +17,8 @@
#include <vector>
#include <aoc/Grid.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Grid.hpp>
#include <aoc/framework/Solver.hpp>
class PrintQueue
: public Solver

View File

@ -15,9 +15,9 @@
#pragma once
#include <aoc/RedNosedReportData.hpp>
#include <aoc/Slope.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Slope.hpp>
#include <aoc/extra/RedNosedReportData.hpp>
#include <aoc/framework/Solver.hpp>
class RedNosedReports
: public Solver

View File

@ -18,10 +18,10 @@
#include <list>
#include <vector>
#include <aoc/LinesSolver.hpp>
#include <aoc/ReindeerMazeCrossing.hpp>
#include <aoc/ReindeerMazePathIncidence.hpp>
#include <aoc/WeightedEdgeGraph.hpp>
#include <aoc/common/WeightedEdgeGraph.hpp>
#include <aoc/extra/ReindeerMazeCrossing.hpp>
#include <aoc/extra/ReindeerMazePathIncidence.hpp>
#include <aoc/framework/LinesSolver.hpp>
class ReindeerMaze
: public LinesSolver

View File

@ -18,9 +18,9 @@
#include <map>
#include <vector>
#include <aoc/Grid.hpp>
#include <aoc/LinesSolver.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Grid.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/LinesSolver.hpp>
class ResonantCollinearity
: public LinesSolver

View File

@ -18,8 +18,8 @@
#include <array>
#include <vector>
#include <aoc/Point2.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/Solver.hpp>
class RestroomRedoubt
: public Solver

View File

@ -15,10 +15,10 @@
#pragma once
#include <aoc/Lines.hpp>
#include <aoc/LinesSolver.hpp>
#include <aoc/WarehouseBoxPusher.hpp>
#include <aoc/WarehouseWideBoxPusher.hpp>
#include <aoc/common/Lines.hpp>
#include <aoc/extra/WarehouseBoxPusher.hpp>
#include <aoc/extra/WarehouseWideBoxPusher.hpp>
#include <aoc/framework/LinesSolver.hpp>
class WarehouseWoes
: public LinesSolver

View File

@ -19,7 +19,7 @@
#include <memory>
#include <vector>
#include <aoc/Vertex.hpp>
#include <aoc/common/Vertex.hpp>
class Graph
{

View File

@ -17,7 +17,7 @@
#include <memory>
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
// Inspired by https://stackoverflow.com/a/32279494
template <typename T>

View File

@ -19,7 +19,7 @@
#include <string>
#include <vector>
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
/// <summary>
/// A vector of strings of the same length, with methods to treat it as a rectangular, two-dimensional map of char and

View File

@ -17,7 +17,7 @@
#include <vector>
#include <aoc/StringStateMachine.hpp>
#include <aoc/common/StringStateMachine.hpp>
class StringStateMachine;

View File

@ -17,7 +17,7 @@
#include <string>
#include <aoc/StringState.hpp>
#include <aoc/common/StringState.hpp>
class StringState;

View File

@ -17,7 +17,7 @@
#include <vector>
#include <aoc/VertexEdgeIncidence.hpp>
#include <aoc/common/VertexEdgeIncidence.hpp>
class WeightedEdgeGraph
{

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/StringState.hpp>
#include <aoc/common/StringState.hpp>
class MullCharState
: public StringState

View File

@ -15,8 +15,8 @@
#pragma once
#include <aoc/MullData.hpp>
#include <aoc/StringState.hpp>
#include <aoc/common/StringState.hpp>
#include <aoc/extra/MullData.hpp>
class MullDataState
: public StringState

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/MullDataState.hpp>
#include <aoc/extra/MullDataState.hpp>
class MullDoOpenState
: public MullDataState

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/StringState.hpp>
#include <aoc/common/StringState.hpp>
class MullEntryState
: public StringState

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/MullDataState.hpp>
#include <aoc/extra/MullDataState.hpp>
class MullFactorState
: public MullDataState

View File

@ -15,11 +15,11 @@
#pragma once
#include <aoc/MullCharState.hpp>
#include <aoc/MullDoOpenState.hpp>
#include <aoc/MullEntryState.hpp>
#include <aoc/MullFactorState.hpp>
#include <aoc/MullToggleCloseState.hpp>
#include <aoc/extra/MullCharState.hpp>
#include <aoc/extra/MullDoOpenState.hpp>
#include <aoc/extra/MullEntryState.hpp>
#include <aoc/extra/MullFactorState.hpp>
#include <aoc/extra/MullToggleCloseState.hpp>
class MullStates
{

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/MullDataState.hpp>
#include <aoc/extra/MullDataState.hpp>
class MullToggleCloseState
: public MullDataState

View File

@ -17,7 +17,7 @@
#include<vector>
#include <aoc/Slope.hpp>
#include <aoc/common/Slope.hpp>
class RedNosedReportData
{

View File

@ -17,8 +17,8 @@
#include <vector>
#include <aoc/Point2.hpp>
#include <aoc/ReindeerMazePathIncidence.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/extra/ReindeerMazePathIncidence.hpp>
class ReindeerMazeCrossing
{

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
class ReindeerMazePathIncidence
{

View File

@ -18,8 +18,8 @@
#include <string>
#include <vector>
#include <aoc/Lines.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Lines.hpp>
#include <aoc/common/Point2.hpp>
class WarehouseBoxPusher
{

View File

@ -15,7 +15,7 @@
#pragma once
#include <aoc/WarehouseBoxPusher.hpp>
#include <aoc/extra/WarehouseBoxPusher.hpp>
class WarehouseWideBoxPusher
: public WarehouseBoxPusher

View File

@ -17,9 +17,9 @@
#include <vector>
#include <aoc/Lines.hpp>
#include <aoc/Point2.hpp>
#include <aoc/Solver.hpp>
#include <aoc/common/Lines.hpp>
#include <aoc/common/Point2.hpp>
#include <aoc/framework/Solver.hpp>
class LinesSolver
: public Solver

View File

@ -20,7 +20,7 @@
#include <memory>
#include <vector>
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
class SolverEngine
{

View File

@ -18,7 +18,7 @@
#include <cmath>
#include <sstream>
#include <aoc/Math.hpp>
#include <aoc/common/Math.hpp>
const std::string BridgeRepair::getPuzzleName() const
{

View File

@ -19,8 +19,8 @@
#include <queue>
#include <vector>
#include <aoc/Grid.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Grid.hpp>
#include <aoc/common/Point2.hpp>
const std::string HoofIt::getPuzzleName() const
{

View File

@ -15,7 +15,7 @@
#include <aoc/MullItOver.hpp>
#include <aoc/StringStateMachine.hpp>
#include <aoc/common/StringStateMachine.hpp>
MullItOver::MullItOver()
: Solver{}, data_{}, states_ { data_ }

View File

@ -18,7 +18,7 @@
#include <iostream>
#include <memory>
#include <aoc/SolverEngine.hpp>
#include <aoc/framework/SolverEngine.hpp>
// Solver implementations in day order.
#include <aoc/HistorianHysteria.hpp>

View File

@ -21,8 +21,8 @@
#include <numeric>
#include <sstream>
#include <aoc/Math.hpp>
#include <aoc/Point2.hpp>
#include <aoc/common/Math.hpp>
#include <aoc/common/Point2.hpp>
RestroomRedoubt::RestroomRedoubt(const int width, const int height, const bool runPart2)
: width_{ width }, height_{ height }, halfWidth_{ width / 2 }, halfHeight_{ height / 2 }, runPart2_{ runPart2 }

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Graph.hpp>
#include <aoc/common/Graph.hpp>
#include <memory>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Lines.hpp>
#include <aoc/common/Lines.hpp>
#include <algorithm>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Math.hpp>
#include <aoc/common/Math.hpp>
#include <array>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Point2.hpp>
#include <aoc/common/Point2.hpp>
const Point2 Point2::left{ -1, 0 };
const Point2 Point2::right{ 1, 0 };

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/StringStateMachine.hpp>
#include <aoc/common/StringStateMachine.hpp>
StringStateMachine::StringStateMachine(const std::string& line, StringState& entryState)
{

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Vertex.hpp>
#include <aoc/common/Vertex.hpp>
#include <memory>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/WeightedEdgeGraph.hpp>
#include <aoc/common/WeightedEdgeGraph.hpp>
#include <limits>
#include <queue>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullCharState.hpp>
#include <aoc/extra/MullCharState.hpp>
MullCharState::MullCharState(const char expected)
: expected_{ expected }, successState_{}, failState_{}

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullData.hpp>
#include <aoc/extra/MullData.hpp>
MullData::MullData()
: isEnabled_{ true }, factor1_{ 0 }, factor2_{ 0 }, part1_{ 0 }, part2_{ 0 }

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullDataState.hpp>
#include <aoc/extra/MullDataState.hpp>
void MullDataState::setData(MullData& data)
{

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullDoOpenState.hpp>
#include <aoc/extra/MullDoOpenState.hpp>
void MullDoOpenState::next(StringStateMachine* stateMachine)
{

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullEntryState.hpp>
#include <aoc/extra/MullEntryState.hpp>
void MullEntryState::enter(StringStateMachine* stateMachine)
{

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullFactorState.hpp>
#include <aoc/extra/MullFactorState.hpp>
MullFactorState::MullFactorState(const char expected, const int index)
: expected_{ expected }, index_{ index }, successState_{}, failState_{}

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullStates.hpp>
#include <aoc/extra/MullStates.hpp>
MullStates::MullStates(MullData& data)
{

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullToggleCloseState.hpp>
#include <aoc/extra/MullToggleCloseState.hpp>
MullToggleCloseState::MullToggleCloseState(const bool isEnabler)
: isEnabler_{ isEnabler }, successState_{}

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/ReindeerMazeCrossing.hpp>
#include <aoc/extra/ReindeerMazeCrossing.hpp>
ReindeerMazeCrossing::ReindeerMazeCrossing(const Point2 position)
: position_{ position }, incidences{}
@ -27,6 +27,6 @@ Point2 ReindeerMazeCrossing::getPosition() const
bool ReindeerMazeCrossing::isFinished() const
{
return std::find_if(incidences.begin(), incidences.end(), [](auto& x) { return x.getPathVertex() < 0; }) ==
incidences.end();
return std::find_if(incidences.begin(), incidences.end(),
[](auto& x) { return x.getPathVertex() < 0; }) == incidences.end();
}

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/ReindeerMazePathIncidence.hpp>
#include <aoc/extra/ReindeerMazePathIncidence.hpp>
ReindeerMazePathIncidence::ReindeerMazePathIncidence(const Point2 direction)
: ReindeerMazePathIncidence(direction, -1)

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/WarehouseBoxPusher.hpp>
#include <aoc/extra/WarehouseBoxPusher.hpp>
WarehouseBoxPusher::WarehouseBoxPusher(const char boxChar, const char wallChar, const char emptyChar)
: boxChar_{ boxChar }, wallChar_{ wallChar }, emptyChar_{ emptyChar }

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/WarehouseWideBoxPusher.hpp>
#include <aoc/extra/WarehouseWideBoxPusher.hpp>
#include <stack>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/LinesSolver.hpp>
#include <aoc/framework/LinesSolver.hpp>
LinesSolver::LinesSolver(const int inputFileNameSuffix)
: Solver{ inputFileNameSuffix }

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
#include <sstream>

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/SolverEngine.hpp>
#include <aoc/framework/SolverEngine.hpp>
#include <fstream>
#include <iostream>

View File

@ -19,7 +19,7 @@
#include <string>
#include <vector>
#include <aoc/Solver.hpp>
#include <aoc/framework/Solver.hpp>
class TestContext
{

View File

@ -17,7 +17,7 @@
#include <catch2/catch_test_macros.hpp>
#include <aoc/SolverEngine.hpp>
#include <aoc/framework/SolverEngine.hpp>
void TestContext::run(const std::unique_ptr<Solver>&& solver, const long long int expected1,
const long long int expected2, const std::vector<std::string>& inputPaths)