Files
AdventOfCode/2025/Cpp/AdventHelpers/source/AdventOfCodeSolution.cpp
2025-12-02 01:12:59 -05:00

53 lines
1.7 KiB
C++

#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;
return;
}
auto* problemInput = GetProblemInputFile();
if (!problemInput) {
std::cerr << "Failed to load problem input file." << std::endl;
AdventHelpers::InputFileHelper::destroy(exampleInput);
return;
}
// Problem 01, example input
std::cout << "Solving problem 01 using example input..." << std::endl;
auto exampleResult01 = SolveProblem01(*exampleInput);
std::cout << "|- Got result: " << exampleResult01 << std::endl;
// Problem 01, puzzle input
std::cout << "Solving problem 01 using puzzle input..." << std::endl;
auto problemResult01 = SolveProblem01(*problemInput);
std::cout << "|- Got result: " << problemResult01 << std::endl;
// Problem 02, example input
std::cout << "Solving problem 02 using example input..." << std::endl;
auto exampleResult02 = SolveProblem02(*exampleInput);
std::cout << "|- Got result: " << exampleResult02 << std::endl;
// Problem 02, puzzle input
std::cout << "Solving problem 02 using puzzle input..." << std::endl;
auto problemResult02 = SolveProblem02(*problemInput);
std::cout << "|- Got result: " << problemResult02 << std::endl;
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