#pragma region Hidden Setup Stuff #define OLC_PGE_APPLICATION #include "olcPixelGameEngine.h" using namespace olc; enum Run{ FILE1, FILE2 }; // Override base class with your custom functionality class AoC2023 : public olc::PixelGameEngine { std::vectorlines; bool waitForRender=false; void wait(int pauseMs=0){ waitForRender=true; while(waitForRender); std::this_thread::sleep_for(std::chrono::milliseconds(pauseMs)); } #pragma endregion #include const int DAY = 1; Run runInput=FILE1; void doStuff2(){ while(true){ //lines is accessible as a global. std::mapnumberWord{ {0,"zero"}, {1,"one"}, {2,"two"}, {3,"three"}, {4,"four"}, {5,"five"}, {6,"six"}, {7,"seven"}, {8,"eight"}, {9,"nine"}, }; int sum=0; int lineCount=0; for(std::string&line:lines){ lineCount++; int digitFrontIndex=-1; int digitBackIndex=-1; std::arraywordDigitIndexFront; std::arraywordDigitIndexBack; wordDigitIndexFront.fill(-1); wordDigitIndexBack.fill(-1); for(int i=0;i<10;i++){ wordDigitIndexFront[i]=line.find(numberWord[i]); } for(int i=0;i<10;i++){ wordDigitIndexBack[i]=line.rfind(numberWord[i]); } for(int i=0;i='0'&&line[i]<='9'){ digitFrontIndex=i; break; } } for(int i=line.size()-1;i>=0;i--){ if(line[i]>='0'&&line[i]<='9'){ digitBackIndex=i; break; } } int lowestFrontIndex=std::numeric_limits::max(); int highestBackIndex=std::numeric_limits::min(); int frontDigit=0; int backDigit=0; for(int i=0;i<10;i++){ if(wordDigitIndexFront[i]==std::string::npos)continue; if(lowestFrontIndex>wordDigitIndexFront[i]){ lowestFrontIndex=wordDigitIndexFront[i]; frontDigit=i; } } if(digitFrontIndex!=-1&&lowestFrontIndex>digitFrontIndex){ lowestFrontIndex=digitFrontIndex; frontDigit=line[digitFrontIndex]-'0'; } for(int i=0;i<10;i++){ if(wordDigitIndexBack[i]==std::string::npos)continue; if(highestBackIndex=10||backDigit>=10)throw; std::cout<='0'&&line[i]<='9'){ digitFront=line[i]-'0'; } } for(int i=line.size()-1;i>=0;i--){ if(line[i]>='0'&&line[i]<='9'){ digitBack=line[i]-'0'; } } sum+=digitBack*10+digitFront; //std::cout<