Add solution to day 2
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user