Add solution to day 2

This commit is contained in:
Jose Caban
2025-12-02 01:12:59 -05:00
parent b2c1ba8227
commit 3e35b16388
7 changed files with 135 additions and 6 deletions

View File

@@ -14,12 +14,12 @@ namespace AdventHelpers {
inline LinesType::const_iterator begin() const;
inline LinesType::const_iterator end() const;
const char* getLine(size_t index);
private:
InputFileHelper() = default;
~InputFileHelper() = default;
const char* getLine();
LinesType mLines;
};

View File

@@ -1,9 +1,13 @@
#include "AdventHelpers/AdventOfCodeSolution.h"
#define ENABLE_EXCEPTION_HANDLING 0
namespace AdventHelpers
{
void AdventOfCodeSolution::SolveAll() {
#if ENABLE_EXCEPTION_HANDLING
try {
#endif
auto* exampleInput = GetExampleInputFile();
if (!exampleInput) {
std::cerr << "Failed to load example input file." << std::endl;
@@ -39,9 +43,11 @@ namespace AdventHelpers
AdventHelpers::InputFileHelper::destroy(exampleInput);
AdventHelpers::InputFileHelper::destroy(problemInput);
#if ENABLE_EXCEPTION_HANDLING
}
catch (...) {
std::cerr << "An unexpected error occurred while solving the problems." << std::endl;
}
#endif
}
} // namespace AdventHelpers

View File

@@ -28,8 +28,8 @@ namespace AdventHelpers {
return inputFileHelper;
}
const char* InputFileHelper::getLine() {
return nullptr;
const char* InputFileHelper::getLine(size_t index) {
return mLines[index].c_str();
}
void InputFileHelper::destroy(InputFileHelper* inputFileHelper) {