Added sub folders for common, extra, and framework code files
This commit is contained in:
33
include/aoc/extra/MullCharState.hpp
Normal file
33
include/aoc/extra/MullCharState.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/common/StringState.hpp>
|
||||
|
||||
class MullCharState
|
||||
: public StringState
|
||||
{
|
||||
public:
|
||||
MullCharState(const char expected);
|
||||
void enter(StringStateMachine* stateMachine) override {};
|
||||
void next(StringStateMachine* stateMachine) override;
|
||||
void exit(StringStateMachine* stateMachine) override {};
|
||||
void setTransitions(StringState& successState, StringState& failState);
|
||||
private:
|
||||
char expected_;
|
||||
StringState* successState_;
|
||||
StringState* failState_;
|
||||
};
|
||||
35
include/aoc/extra/MullData.hpp
Normal file
35
include/aoc/extra/MullData.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
class MullData
|
||||
{
|
||||
public:
|
||||
MullData();
|
||||
bool getIsEnabled();
|
||||
void setIsEnabled(const bool value);
|
||||
int getFactor(const int index);
|
||||
void setFactor(const int index, const int value);
|
||||
void updateResult();
|
||||
long long int getResultPart1();
|
||||
long long int getResultPart2();
|
||||
private:
|
||||
bool isEnabled_;
|
||||
int factor1_;
|
||||
int factor2_;
|
||||
long long int part1_;
|
||||
long long int part2_;
|
||||
};
|
||||
28
include/aoc/extra/MullDataState.hpp
Normal file
28
include/aoc/extra/MullDataState.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/common/StringState.hpp>
|
||||
#include <aoc/extra/MullData.hpp>
|
||||
|
||||
class MullDataState
|
||||
: public StringState
|
||||
{
|
||||
public:
|
||||
void setData(MullData& data);
|
||||
protected:
|
||||
MullData* data_{ nullptr };
|
||||
};
|
||||
32
include/aoc/extra/MullDoOpenState.hpp
Normal file
32
include/aoc/extra/MullDoOpenState.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/extra/MullDataState.hpp>
|
||||
|
||||
class MullDoOpenState
|
||||
: public MullDataState
|
||||
{
|
||||
public:
|
||||
void enter(StringStateMachine* stateMachine) override {};
|
||||
void next(StringStateMachine* stateMachine) override;
|
||||
void exit(StringStateMachine* stateMachine) override {};
|
||||
void setTransitions(StringState& doState, StringState& dontState, StringState& failState);
|
||||
private:
|
||||
StringState* doState_;
|
||||
StringState* dontState_;
|
||||
StringState* failState_;
|
||||
};
|
||||
31
include/aoc/extra/MullEntryState.hpp
Normal file
31
include/aoc/extra/MullEntryState.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/common/StringState.hpp>
|
||||
|
||||
class MullEntryState
|
||||
: public StringState
|
||||
{
|
||||
public:
|
||||
void enter(StringStateMachine* stateMachine) override;
|
||||
void next(StringStateMachine* stateMachine) override;
|
||||
void exit(StringStateMachine* stateMachine) override {};
|
||||
void setTransitions(StringState& mulState, StringState& doState);
|
||||
private:
|
||||
StringState* mulState_;
|
||||
StringState* doState_;
|
||||
};
|
||||
34
include/aoc/extra/MullFactorState.hpp
Normal file
34
include/aoc/extra/MullFactorState.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/extra/MullDataState.hpp>
|
||||
|
||||
class MullFactorState
|
||||
: public MullDataState
|
||||
{
|
||||
public:
|
||||
MullFactorState(const char expected, const int index);
|
||||
void enter(StringStateMachine* stateMachine) override;
|
||||
void next(StringStateMachine* stateMachine) override;
|
||||
void exit(StringStateMachine* stateMachine) override {};
|
||||
void setTransitions(StringState& successState, StringState& failState);
|
||||
private:
|
||||
char expected_;
|
||||
int index_;
|
||||
StringState* successState_;
|
||||
StringState* failState_;
|
||||
};
|
||||
41
include/aoc/extra/MullStates.hpp
Normal file
41
include/aoc/extra/MullStates.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#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
|
||||
{
|
||||
public:
|
||||
MullStates(MullData& data);
|
||||
MullEntryState entryState;
|
||||
MullCharState uState{ 'u' };
|
||||
MullCharState lState{ 'l' };
|
||||
MullCharState mulOpenState{ '(' };
|
||||
MullFactorState factor1State{ ',', 1 };
|
||||
MullFactorState factor2State{ ')', 2 };
|
||||
MullCharState oState{ 'o' };
|
||||
MullDoOpenState doOpenState;
|
||||
MullToggleCloseState doCloseState{ true };
|
||||
MullCharState apostropheState{ '\'' };
|
||||
MullCharState tState{ 't' };
|
||||
MullCharState dontOpenState{ '(' };
|
||||
MullToggleCloseState dontCloseState{ false };
|
||||
};
|
||||
32
include/aoc/extra/MullToggleCloseState.hpp
Normal file
32
include/aoc/extra/MullToggleCloseState.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/extra/MullDataState.hpp>
|
||||
|
||||
class MullToggleCloseState
|
||||
: public MullDataState
|
||||
{
|
||||
public:
|
||||
MullToggleCloseState(const bool isEnabler);
|
||||
void enter(StringStateMachine* stateMachine) override {};
|
||||
void next(StringStateMachine* stateMachine) override;
|
||||
void exit(StringStateMachine* stateMachine) override {};
|
||||
void setTransitions(StringState& successState);
|
||||
private:
|
||||
bool isEnabler_;
|
||||
StringState* successState_;
|
||||
};
|
||||
32
include/aoc/extra/RedNosedReportData.hpp
Normal file
32
include/aoc/extra/RedNosedReportData.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include<vector>
|
||||
|
||||
#include <aoc/common/Slope.hpp>
|
||||
|
||||
class RedNosedReportData
|
||||
{
|
||||
public:
|
||||
bool isSafe{ true };
|
||||
bool canUseDampener{ true };
|
||||
bool mustSkipPrevious{ false };
|
||||
bool mustCheckSlopeReversal{ false };
|
||||
bool mustAwaitFourLevels{ false };
|
||||
Slope slope{ Slope::Unknown };
|
||||
std::vector<int> levels{};
|
||||
};
|
||||
32
include/aoc/extra/ReindeerMazeCrossing.hpp
Normal file
32
include/aoc/extra/ReindeerMazeCrossing.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2025 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <aoc/common/Point2.hpp>
|
||||
#include <aoc/extra/ReindeerMazePathIncidence.hpp>
|
||||
|
||||
class ReindeerMazeCrossing
|
||||
{
|
||||
public:
|
||||
ReindeerMazeCrossing(const Point2 position);
|
||||
Point2 getPosition() const;
|
||||
bool isFinished() const;
|
||||
std::vector<ReindeerMazePathIncidence> incidences;
|
||||
private:
|
||||
Point2 position_;
|
||||
};
|
||||
34
include/aoc/extra/ReindeerMazePathIncidence.hpp
Normal file
34
include/aoc/extra/ReindeerMazePathIncidence.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2025 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/common/Point2.hpp>
|
||||
|
||||
class ReindeerMazePathIncidence
|
||||
{
|
||||
public:
|
||||
ReindeerMazePathIncidence(const Point2 direction);
|
||||
ReindeerMazePathIncidence(const Point2 direction, const int pathVertex);
|
||||
Point2 getDirection() const;
|
||||
int getPathVertex() const;
|
||||
void setPathVertex(const int pathVertex);
|
||||
int getPathCost() const;
|
||||
void setPathCost(const int pathCost);
|
||||
private:
|
||||
Point2 direction_;
|
||||
int pathVertex_;
|
||||
int pathCost_;
|
||||
};
|
||||
37
include/aoc/extra/WarehouseBoxPusher.hpp
Normal file
37
include/aoc/extra/WarehouseBoxPusher.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2025 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <aoc/common/Lines.hpp>
|
||||
#include <aoc/common/Point2.hpp>
|
||||
|
||||
class WarehouseBoxPusher
|
||||
{
|
||||
public:
|
||||
WarehouseBoxPusher(const char boxChar, const char wallChar, const char emptyChar);
|
||||
virtual ~WarehouseBoxPusher(){};
|
||||
virtual void processMovements(Lines& warehouseMap, const std::string& line);
|
||||
virtual void processMovement(Lines& warehouseMap, const Point2& direction);
|
||||
void setRobotPosition(const Point2& robotPosition);
|
||||
protected:
|
||||
Point2 robotPosition_;
|
||||
const char boxChar_;
|
||||
const char wallChar_;
|
||||
const char emptyChar_;
|
||||
};
|
||||
30
include/aoc/extra/WarehouseWideBoxPusher.hpp
Normal file
30
include/aoc/extra/WarehouseWideBoxPusher.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2025 Stefan Müller
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation, either version 3 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aoc/extra/WarehouseBoxPusher.hpp>
|
||||
|
||||
class WarehouseWideBoxPusher
|
||||
: public WarehouseBoxPusher
|
||||
{
|
||||
public:
|
||||
WarehouseWideBoxPusher(const char leftWideBoxChar, const char rightWideBoxChar, const char wallChar,
|
||||
const char emptyChar);
|
||||
virtual void processMovement(Lines& warehouseMap, const Point2& direction) override;
|
||||
protected:
|
||||
const char leftWideBoxChar_;
|
||||
const char rightWideBoxChar_;
|
||||
};
|
||||
Reference in New Issue
Block a user