Merge branch 'cmake'

This commit is contained in:
Stefan Müller 2024-12-08 10:50:06 +01:00
commit 78d0f59886
67 changed files with 357 additions and 925 deletions

31
.clang-format Normal file
View File

@ -0,0 +1,31 @@
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
ColumnLimit: 100
EmptyLineBeforeAccessModifier: Never
FixNamespaceComments: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: "^<[a-z]*>"
Priority: 1
- Regex: "^<.*/.*>"
Priority: 2
- Regex: '^<.*\.hpp>'
Priority: 3
- Regex: '^<.*\.h>'
Priority: 4
- Regex: ".*"
Priority: 5
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
InsertNewlineAtEOF: true
NamespaceIndentation: All
PointerAlignment: Left
ReferenceAlignment: Left
SortIncludes: CaseInsensitive
SpaceBeforeCaseColon: true
SpaceBeforeParens: ControlStatements

30
.clang-tidy Normal file
View File

@ -0,0 +1,30 @@
---
# Enable all by default, then disable some that have either too many warnings
# at the moment or ones that don't make sense for our codebase
Checks: clang-diagnostic-*
clang-analyzer-*
cppcoreguidelines-*
modernize-*
hicpp-*
-hicpp-special-member-functions
-modernize-pass-by-value
-cppcoreguidelines-pro-bounds-constant-array-index
-modernize-use-trailing-return-type
-cppcoreguidelines-avoid-non-const-global-variables
-hicpp-signed-bitwise
-hicpp-vararg
-hicpp-braces-around-statements
-hicpp-no-array-decay
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-non-private-member-variables-in-classes
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-pro-type-vararg
-modernize-avoid-c-arrays
-cppcoreguidelines-avoid-c-arrays
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-narrowing-conversions
-clang-analyzer-deadcode.DeadStores
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
...

37
.gitattributes vendored Normal file
View File

@ -0,0 +1,37 @@
# Sources
*.c text diff=cpp
*.cc text diff=cpp
*.cxx text diff=cpp
*.cpp text diff=cpp
*.cpi text diff=cpp
*.c++ text diff=cpp
*.hpp text diff=cpp
*.h text diff=cpp
*.h++ text diff=cpp
*.hh text diff=cpp
# Compiled Object files
*.slo binary
*.lo binary
*.o binary
*.obj binary
# Precompiled Headers
*.gch binary
*.pch binary
# Compiled Dynamic libraries
*.so binary
*.dylib binary
*.dll binary
# Compiled Static libraries
*.lai binary
*.la binary
*.a binary
*.lib binary
# Executables
*.exe binary
*.out binary
*.app binary

1
.gitignore vendored
View File

@ -36,3 +36,4 @@
.vs .vs
Debug/ Debug/
*.vcxproj.user *.vcxproj.user
build/

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "Program.h" #include <aoc/Program.h>
int main() int main()
{ {

View File

@ -1,82 +0,0 @@
# Visual Studio generated .editorconfig file with C++ settings.
root = true
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Code Style settings
cpp_generate_documentation_comments = xml
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = true
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = ignore
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_new_line_scope_braces_on_separate_lines = false
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = left
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
# Visual C++ Inlcude Cleanup settings
cpp_include_cleanup_add_missing_error_tag_type = suggestion
cpp_include_cleanup_remove_unused_error_tag_type = dimmed
cpp_include_cleanup_optimize_unused_error_tag_type = suggestion
cpp_include_cleanup_sort_after_edits = false
cpp_sort_includes_error_tag_type = none
cpp_sort_includes_priority_case_sensitive = false
cpp_sort_includes_priority_style = quoted
cpp_includes_style = default
cpp_includes_use_forward_slash = true

View File

@ -1,41 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AdventOfCode2024", "AdventOfCode2024.vcxproj", "{0DEDB176-15A1-48C2-B710-5F17538C5DEC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests\UnitTests.vcxproj", "{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Debug|x64.ActiveCfg = Debug|x64
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Debug|x64.Build.0 = Debug|x64
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Debug|x86.ActiveCfg = Debug|Win32
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Debug|x86.Build.0 = Debug|Win32
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Release|x64.ActiveCfg = Release|x64
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Release|x64.Build.0 = Release|x64
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Release|x86.ActiveCfg = Release|Win32
{0DEDB176-15A1-48C2-B710-5F17538C5DEC}.Release|x86.Build.0 = Release|Win32
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Debug|x64.ActiveCfg = Debug|x64
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Debug|x64.Build.0 = Debug|x64
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Debug|x86.ActiveCfg = Debug|Win32
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Debug|x86.Build.0 = Debug|Win32
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Release|x64.ActiveCfg = Release|x64
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Release|x64.Build.0 = Release|x64
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Release|x86.ActiveCfg = Release|Win32
{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09BCF972-2454-4BE3-9637-D49111238A7F}
EndGlobalSection
EndGlobal

View File

@ -1,182 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{0dedb176-15a1-48c2-b710-5f17538c5dec}</ProjectGuid>
<RootNamespace>AdventOfCode2024</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AdventOfCode2024.cpp" />
<ClCompile Include="CeresSearch.cpp" />
<ClCompile Include="GuardGallivant.cpp" />
<ClCompile Include="HistorianHysteria.cpp" />
<ClCompile Include="LinesSolver.cpp" />
<ClCompile Include="MullDataState.cpp" />
<ClCompile Include="MullToggleCloseState.cpp" />
<ClCompile Include="MullDoOpenState.cpp" />
<ClCompile Include="MullEntryState.cpp" />
<ClCompile Include="MullData.cpp" />
<ClCompile Include="MullFactorState.cpp" />
<ClCompile Include="MullItOver.cpp" />
<ClCompile Include="MullStates.cpp" />
<ClCompile Include="MullCharState.cpp" />
<ClCompile Include="Point2.cpp" />
<ClCompile Include="PrintQueue.cpp" />
<ClCompile Include="Program.cpp" />
<ClCompile Include="RedNosedReports.cpp" />
<ClCompile Include="Solver.cpp" />
<ClCompile Include="SolverEngine.cpp" />
<ClCompile Include="StringState.cpp" />
<ClCompile Include="StringStateMachine.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CeresSearch.h" />
<ClInclude Include="GuardGallivant.h" />
<ClInclude Include="HistorianHysteria.h" />
<ClInclude Include="LinesSolver.h" />
<ClInclude Include="MullDataState.h" />
<ClInclude Include="MullToggleCloseState.h" />
<ClInclude Include="MullDoOpenState.h" />
<ClInclude Include="MullEntryState.h" />
<ClInclude Include="MullData.h" />
<ClInclude Include="MullFactorState.h" />
<ClInclude Include="MullItOver.h" />
<ClInclude Include="MullStates.h" />
<ClInclude Include="MullCharState.h" />
<ClInclude Include="Point2.h" />
<ClInclude Include="PrintQueue.h" />
<ClInclude Include="Program.h" />
<ClInclude Include="RedNosedReportData.h" />
<ClInclude Include="RedNosedReports.h" />
<ClInclude Include="Slope.h" />
<ClInclude Include="Solver.h" />
<ClInclude Include="SolverEngine.h" />
<ClInclude Include="StringState.h" />
<ClInclude Include="StringStateMachine.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,156 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AdventOfCode2024.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Solver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SolverEngine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Program.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HistorianHysteria.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RedNosedReports.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullItOver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StringStateMachine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StringState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullEntryState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullCharState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullFactorState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullDoOpenState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullToggleCloseState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullDataState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MullStates.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Point2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CeresSearch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LinesSolver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PrintQueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GuardGallivant.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SolverEngine.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Solver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Program.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HistorianHysteria.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RedNosedReports.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullItOver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StringStateMachine.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StringState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullEntryState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullCharState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullFactorState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullDoOpenState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullToggleCloseState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RedNosedReportData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Slope.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullStates.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MullDataState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Point2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CeresSearch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LinesSolver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PrintQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GuardGallivant.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1 +0,0 @@
#include "StringState.h"

View File

@ -1,82 +0,0 @@
// 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/>.
#include "pch.h"
#include "CppUnitTest.h"
#include "Part1TestContext.h"
#include "Part2TestContext.h"
#include "../Solver.h"
#include "../SolverEngine.h"
#include "../HistorianHysteria.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTests
{
TEST_CLASS(HistorianHysteriaTests)
{
public:
TEST_METHOD(FullData1)
{
runTest(*std::make_unique<HistorianHysteria>(), 2176849, part1TestContext_);
}
TEST_METHOD(FullData2)
{
runTest(*std::make_unique<HistorianHysteria>(), 23384288, part2TestContext_);
}
TEST_METHOD(ExampleData1)
{
runTest(*std::make_unique<HistorianHysteria>(), 11, part1ExampleTestContext_);
}
TEST_METHOD(ExampleData2)
{
runTest(*std::make_unique<HistorianHysteria>(), 31, part2ExampleTestContext_);
}
private:
Part1TestContext part1TestContext_{ getInputPaths() };
Part2TestContext part2TestContext_{ getInputPaths() };
Part1TestContext part1ExampleTestContext_{ getExampleInputPaths() };
Part2TestContext part2ExampleTestContext_{ getExampleInputPaths() };
void runTest(Solver& solver, const long long int expected, const TestContext& context)
{
SolverEngine solverEngine{ context.getInputPaths() };
solverEngine.run(solver);
assertAreEqual(expected, context.getResult(solver));
}
std::vector<std::string> getInputPaths() const
{
return std::vector<std::string>{ "../../data", "../../../../data" };
}
std::vector<std::string> getExampleInputPaths() const
{
return std::vector<std::string>{ "../../data/examples", "../../../../data/examples" };
}
void assertAreEqual(const long long int expected, const long long int actual) const
{
std::wstring message = L"Expected: <" + std::to_wstring(expected) + L"> Actual: <" + std::to_wstring(actual) + L">";
Assert::IsTrue(expected == actual, message.c_str());
}
};
}

View File

@ -1,187 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectGuid>{15C7DA0D-C4D8-420B-AC10-D213AD22B9FA}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>UnitTests</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Solver.obj;SolverEngine.obj;HistorianHysteria.obj;RedNosedReports.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Part1TestContext.cpp" />
<ClCompile Include="Part2TestContext.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TestContext.cpp" />
<ClCompile Include="UnitTests.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Part1TestContext.h" />
<ClInclude Include="Part2TestContext.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="TestContext.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AdventOfCode2024.vcxproj">
<Project>{0dedb176-15a1-48c2-b710-5f17538c5dec}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="UnitTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Part1TestContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Part2TestContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Part1TestContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Part2TestContext.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,5 +0,0 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@ -1,12 +0,0 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#endif //PCH_H

57
CMakeLists.txt Normal file
View File

@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
Include(FetchContent)
set(CMAKE_CXX_STANDARD 23) # latest c++
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# prepare out unit test framework
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
)
FetchContent_MakeAvailable(Catch2)
# Versioning
project ("AdventOfCode2024" VERSION 0.0.1 DESCRIPTION "" LANGUAGES CXX)
# ---
# Grab source files
file(GLOB_RECURSE AdventOfCode2024Sources
"include/*.h"
"include/*.hpp"
"src/*.c"
"src/*.cpp"
)
file(GLOB_RECURSE AdventOfCode2024Tests
"tests/include/*.h"
"tests/include/*.hpp"
"tests/src/*.c"
"tests/src/*.cpp"
)
# Project setup
set(output_target AdventOfCode2024)
# This is split in 2 because catch2 generates its own main() functions
# and we don't want to recompile everything twice, so we reuse the lib object.
# lib
# / \
# main exe catch2
# Library to contain logic/code
add_library(${output_target}-lib ${AdventOfCode2024Sources})
target_include_directories(${output_target}-lib PUBLIC "include")
# Executable that links to the lib containing the code
add_executable(${output_target} "AdventOfCode2024.cpp")
target_link_libraries(${output_target} PRIVATE ${output_target}-lib)
# Catch2 linked with the lib.
add_executable(${output_target}-tests ${AdventOfCode2024Tests})
target_include_directories(${output_target}-tests PRIVATE "tests/include")
target_link_libraries(${output_target}-tests PRIVATE
${output_target}-lib
Catch2::Catch2WithMain
)

View File

@ -2,7 +2,7 @@
Solver for Advent of Code 2024 puzzles. <https://adventofcode.com/2024/> Solver for Advent of Code 2024 puzzles. <https://adventofcode.com/2024/>
This is a single command line application for the puzzles written in [C++17](https://en.cppreference.com/w/cpp/17) with [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) (v143). This is a single command line application for the puzzles written in [C++23](https://en.cppreference.com/w/cpp/23) with CMake.
## Puzzle Input ## Puzzle Input
@ -44,6 +44,10 @@ For this puzzle I added a class for [points in two-dimensional space](AdventOfCo
My implementation uses an ordering matrix (a two-dimensional boolean array) to track which page combinations are ordered, and then queries that matrix for each ordered combination of pages in a single line. The same matrix can then also be used for a custom sort function for part 2. My implementation uses an ordering matrix (a two-dimensional boolean array) to track which page combinations are ordered, and then queries that matrix for each ordered combination of pages in a single line. The same matrix can then also be used for a custom sort function for part 2.
## Thanks
* [Alexander Brouwer](https://github.com/Bromvlieg) for getting the project set up with CMake.
## License ## License
Copyright (C) 2024 Stefan Müller Copyright (C) 2024 Stefan Müller

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -17,10 +17,10 @@
#include <set> #include <set>
#include "Solver.h" #include <aoc/Solver.h>
class HistorianHysteria : class HistorianHysteria
public Solver : public Solver
{ {
public: public:
virtual std::string getPuzzleName() const override; virtual std::string getPuzzleName() const override;

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "StringState.h" #include <aoc/StringState.h>
class MullCharState : class MullCharState
public StringState : public StringState
{ {
public: public:
MullCharState(const char expected); MullCharState(const char expected);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,11 +15,11 @@
#pragma once #pragma once
#include "MullData.h" #include <aoc/MullData.h>
#include "StringState.h" #include <aoc/StringState.h>
class MullDataState : class MullDataState
public StringState : public StringState
{ {
public: public:
void setData(MullData& data); void setData(MullData& data);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "MullDataState.h" #include <aoc/MullDataState.h>
class MullDoOpenState : class MullDoOpenState
public MullDataState : public MullDataState
{ {
public: public:
void enter(StringStateMachine* stateMachine) override {}; void enter(StringStateMachine* stateMachine) override {};

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "StringState.h" #include <aoc/StringState.h>
class MullEntryState : class MullEntryState
public StringState : public StringState
{ {
public: public:
void enter(StringStateMachine* stateMachine) override; void enter(StringStateMachine* stateMachine) override;

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "MullDataState.h" #include <aoc/MullDataState.h>
class MullFactorState : class MullFactorState
public MullDataState : public MullDataState
{ {
public: public:
MullFactorState(const char expected, const int index); MullFactorState(const char expected, const int index);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,12 +15,12 @@
#pragma once #pragma once
#include "MullData.h" #include <aoc/MullData.h>
#include "MullStates.h" #include <aoc/MullStates.h>
#include "Solver.h" #include <aoc/Solver.h>
class MullItOver : class MullItOver
public Solver : public Solver
{ {
public: public:
MullItOver(); MullItOver();

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,11 +15,11 @@
#pragma once #pragma once
#include "MullCharState.h" #include <aoc/MullCharState.h>
#include "MullDoOpenState.h" #include <aoc/MullDoOpenState.h>
#include "MullEntryState.h" #include <aoc/MullEntryState.h>
#include "MullFactorState.h" #include <aoc/MullFactorState.h>
#include "MullToggleCloseState.h" #include <aoc/MullToggleCloseState.h>
class MullStates class MullStates
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "MullDataState.h" #include <aoc/MullDataState.h>
class MullToggleCloseState : class MullToggleCloseState
public MullDataState : public MullDataState
{ {
public: public:
MullToggleCloseState(const bool isEnabler); MullToggleCloseState(const bool isEnabler);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -17,7 +17,7 @@
#include<vector> #include<vector>
#include "Slope.h" #include <aoc/Slope.h>
class RedNosedReportData class RedNosedReportData
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,12 +15,12 @@
#pragma once #pragma once
#include "Slope.h" #include <aoc/Slope.h>
#include "Solver.h" #include <aoc/Solver.h>
#include "RedNosedReportData.h" #include <aoc/RedNosedReportData.h>
class RedNosedReports : class RedNosedReports
public Solver : public Solver
{ {
public: public:
std::string getPuzzleName() const override; std::string getPuzzleName() const override;

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -20,13 +20,14 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "Solver.h" #include <aoc/Solver.h>
class SolverEngine class SolverEngine
{ {
public: public:
SolverEngine(const std::vector<std::string>& inputPaths); SolverEngine(const std::vector<std::string>& inputPaths);
void run(Solver& solver); void run(Solver& solver);
private: private:
std::vector<std::string> inputPaths_; std::vector<std::string> inputPaths_;
std::filesystem::path tryGetValidFullInputFilePath(const std::string& inputFileName); std::filesystem::path tryGetValidFullInputFilePath(const std::string& inputFileName);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -17,7 +17,7 @@
#include <vector> #include <vector>
#include "StringStateMachine.h" #include <aoc/StringStateMachine.h>
class StringStateMachine; class StringStateMachine;

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -17,7 +17,7 @@
#include <string> #include <string>
#include "StringState.h" #include <aoc/StringState.h>
class StringState; class StringState;

View File

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

View File

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

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,7 +15,7 @@
#include <iostream> #include <iostream>
#include "HistorianHysteria.h" #include <aoc/HistorianHysteria.h>
std::string HistorianHysteria::getPuzzleName() const std::string HistorianHysteria::getPuzzleName() const
{ {

View File

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

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullCharState.h" #include <aoc/MullCharState.h>
MullCharState::MullCharState(const char expected) MullCharState::MullCharState(const char expected)
: expected_{ expected }, successState_{}, failState_{} {} : expected_{ expected }, successState_{}, failState_{} {}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullData.h" #include <aoc/MullData.h>
MullData::MullData() MullData::MullData()
: isEnabled_{ true }, factor1_{ 0 }, factor2_{ 0 }, part1_{ 0 }, part2_{ 0 } {}; : isEnabled_{ true }, factor1_{ 0 }, factor2_{ 0 }, part1_{ 0 }, part2_{ 0 } {};

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullDataState.h" #include <aoc/MullDataState.h>
void MullDataState::setData(MullData& data) void MullDataState::setData(MullData& data)
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullDoOpenState.h" #include <aoc/MullDoOpenState.h>
void MullDoOpenState::next(StringStateMachine* stateMachine) void MullDoOpenState::next(StringStateMachine* stateMachine)
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullEntryState.h" #include <aoc/MullEntryState.h>
void MullEntryState::enter(StringStateMachine* stateMachine) void MullEntryState::enter(StringStateMachine* stateMachine)
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullFactorState.h" #include <aoc/MullFactorState.h>
MullFactorState::MullFactorState(const char expected, const int index) MullFactorState::MullFactorState(const char expected, const int index)
: expected_{ expected }, index_{ index }, successState_{}, failState_{} {} : expected_{ expected }, index_{ index }, successState_{}, failState_{} {}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,8 +13,8 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullItOver.h" #include <aoc/MullItOver.h>
#include "StringStateMachine.h" #include <aoc/StringStateMachine.h>
MullItOver::MullItOver() MullItOver::MullItOver()
: Solver{}, data_{}, states_ { : Solver{}, data_{}, states_ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullStates.h" #include <aoc/MullStates.h>
MullStates::MullStates(MullData& data) MullStates::MullStates(MullData& data)
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "MullToggleCloseState.h" #include <aoc/MullToggleCloseState.h>
MullToggleCloseState::MullToggleCloseState(const bool isEnabler) MullToggleCloseState::MullToggleCloseState(const bool isEnabler)
: isEnabler_{ isEnabler }, successState_{} {} : isEnabler_{ isEnabler }, successState_{} {}

View File

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

View File

@ -17,7 +17,7 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include "PrintQueue.h" #include <aoc/PrintQueue.h>
PrintQueue::PrintQueue() PrintQueue::PrintQueue()
: Solver{}, pageNoMapIndex_{ 0 }, isProcessingOrderingRules_{ true }, orderingRules_{} : Solver{}, pageNoMapIndex_{ 0 }, isProcessingOrderingRules_{ true }, orderingRules_{}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -16,16 +16,16 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include "Program.h" #include <aoc/Program.h>
#include "SolverEngine.h" #include <aoc/SolverEngine.h>
// Solver implementations in day order. // Solver implementations in day order.
#include "HistorianHysteria.h" #include <aoc/HistorianHysteria.h>
#include "RedNosedReports.h" #include <aoc/RedNosedReports.h>
#include "MullItOver.h" #include <aoc/MullItOver.h>
#include "CeresSearch.h" #include <aoc/CeresSearch.h>
#include "PrintQueue.h" #include <aoc/PrintQueue.h>
#include "GuardGallivant.h" #include <aoc/GuardGallivant.h>
void Program::run() void Program::run()
{ {
@ -46,5 +46,5 @@ void Program::runSolvers()
std::vector<std::string> Program::getInputPaths() const std::vector<std::string> Program::getInputPaths() const
{ {
return std::vector<std::string>{ "data", "../../data" }; return std::vector<std::string>{ "data", "../../../data", "../../../../data" };
} }

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -17,7 +17,7 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include "RedNosedReports.h" #include <aoc/RedNosedReports.h>
std::string RedNosedReports::getPuzzleName() const std::string RedNosedReports::getPuzzleName() const
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "Solver.h" #include <aoc/Solver.h>
Solver::Solver() Solver::Solver()
: part1{ 0 }, part2{ 0 } {} : part1{ 0 }, part2{ 0 } {}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -16,7 +16,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "SolverEngine.h" #include <aoc/SolverEngine.h>
SolverEngine::SolverEngine(const std::vector<std::string>& inputPaths) SolverEngine::SolverEngine(const std::vector<std::string>& inputPaths)
: inputPaths_{ inputPaths } {} : inputPaths_{ inputPaths } {}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "StringStateMachine.h" #include <aoc/StringStateMachine.h>
StringStateMachine::StringStateMachine(const std::string& line, StringState& entryState) StringStateMachine::StringStateMachine(const std::string& line, StringState& entryState)
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "TestContext.h" #include <aocTests/TestContext.h>
class Part1TestContext : class Part1TestContext
public TestContext : public TestContext
{ {
public: public:
Part1TestContext(std::vector<std::string> inputPaths); Part1TestContext(std::vector<std::string> inputPaths);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -15,10 +15,10 @@
#pragma once #pragma once
#include "TestContext.h" #include <aocTests/TestContext.h>
class Part2TestContext : class Part2TestContext
public TestContext : public TestContext
{ {
public: public:
Part2TestContext(std::vector<std::string> inputPaths); Part2TestContext(std::vector<std::string> inputPaths);

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -18,7 +18,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <Solver.h> #include <aoc/Solver.h>
class TestContext class TestContext
{ {

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,8 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "pch.h" #include <aocTests/Part1TestContext.h>
#include "Part1TestContext.h"
Part1TestContext::Part1TestContext(std::vector<std::string> inputPaths) Part1TestContext::Part1TestContext(std::vector<std::string> inputPaths)
: TestContext{ inputPaths } {} : TestContext{ inputPaths } {}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,8 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "pch.h" #include <aocTests/Part2TestContext.h>
#include "Part2TestContext.h"
Part2TestContext::Part2TestContext(std::vector<std::string> inputPaths) Part2TestContext::Part2TestContext(std::vector<std::string> inputPaths)
: TestContext{ inputPaths } {} : TestContext{ inputPaths } {}

70
tests/src/TestCases.cpp Normal file
View File

@ -0,0 +1,70 @@
// 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/>.
#include <aocTests/Part1TestContext.h>
#include <aocTests/Part2TestContext.h>
#include <aoc/Solver.h>
#include <aoc/SolverEngine.h>
#include <aoc/HistorianHysteria.h>
#include <catch2/catch_test_macros.hpp>
#define REQUIRE_MESSAGE(cond, msg) if (!(cond)) { INFO(msg); REQUIRE(cond); }
class HistorianHysteriaTests
{
public:
Part1TestContext part1TestContext_{ getInputPaths() };
Part2TestContext part2TestContext_{ getInputPaths() };
Part1TestContext part1ExampleTestContext_{ getExampleInputPaths() };
Part2TestContext part2ExampleTestContext_{ getExampleInputPaths() };
void runTest(Solver &solver, const long long int expected, const TestContext &context)
{
SolverEngine solverEngine{context.getInputPaths()};
solverEngine.run(solver);
REQUIRE(expected == context.getResult(solver));
}
private:
std::vector<std::string> getInputPaths() const
{
return std::vector<std::string>{ "data", "../../../data", "../../../../data" };
}
std::vector<std::string> getExampleInputPaths() const
{
return std::vector<std::string>{ "data/examples", "../../../data/examples", "../../../../data/examples" };
}
};
TEST_CASE( "[HistorianHysteriaTests]" )
{
HistorianHysteriaTests tests;
SECTION( "FullData1" ) {
tests.runTest(*std::make_unique<HistorianHysteria>(), 2176849, tests.part1TestContext_);
}
SECTION( "FullData2" ) {
tests.runTest(*std::make_unique<HistorianHysteria>(), 23384288, tests.part2TestContext_);
}
SECTION( "ExampleData1" ) {
tests.runTest(*std::make_unique<HistorianHysteria>(), 11, tests.part1ExampleTestContext_);
}
SECTION( "ExampleData2" ) {
tests.runTest(*std::make_unique<HistorianHysteria>(), 31, tests.part2ExampleTestContext_);
}
}

View File

@ -1,5 +1,5 @@
// Solutions to the Advent Of Code 2024. // Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller // Copyright (C) 2024 Stefan Müller
// //
// This program is free software: you can redistribute it and/or modify it under // 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 // the terms of the GNU General Public License as published by the Free Software
@ -13,8 +13,7 @@
// You should have received a copy of the GNU General Public License along with // You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>. // this program. If not, see <http://www.gnu.org/licenses/>.
#include "pch.h" #include <aocTests/TestContext.h>
#include "TestContext.h"
TestContext::TestContext(std::vector<std::string> inputPaths) TestContext::TestContext(std::vector<std::string> inputPaths)
: inputPaths_{ inputPaths } {} : inputPaths_{ inputPaths } {}