#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 const int DAY = 5; Run runInput=FILE2; struct Seed{ long long val; long long range; bool found=false; }; struct Transform{ long long source; long long range; long long dest; }; void doStuff(){ while(true){ //lines is accessible as a global. long long smallest=0; bool firstLine=true; std::vectorseeds; std::vector>transforms; bool newTransform=false; for(std::string&line:lines){ if(firstLine){ firstLine=false; bool IsNumber=true; std::string seedNumbers=line.substr(6); while(seedNumbers.find(' ',1)!=std::string::npos){ size_t spacePos=seedNumbers.find(' ',1); long long numb=atoll(seedNumbers.substr(1,spacePos).c_str()); if(IsNumber){ seeds.push_back({numb}); }else{ Seed&prevSeed=seeds[seeds.size()-1]; prevSeed.range=numb; if(prevSeed.val+prevSeed.range-1>smallest)smallest=prevSeed.val+prevSeed.range-1; } IsNumber=!IsNumber; seedNumbers=seedNumbers.substr(spacePos); } long long numb=atoll(seedNumbers.substr(1).c_str()); if(IsNumber){ seeds.push_back({numb}); }else{ Seed&prevSeed=seeds[seeds.size()-1]; prevSeed.range=numb; if(prevSeed.val+prevSeed.range-1>smallest)smallest=prevSeed.val+prevSeed.range-1; } }else if(line.length()>0){ if(newTransform&&line[0]>='0'&&line[0]<='9'){//This is a conversion std::vector¤tTransform=transforms[transforms.size()-1]; size_t spacePos=line.find(' '); long long dest=atoll(line.substr(0,spacePos).c_str()); size_t prevSpacePos=spacePos; spacePos=line.find(' ',prevSpacePos+1); long long source=atoll(line.substr(prevSpacePos+1,spacePos).c_str()); prevSpacePos=spacePos; spacePos=line.find(' ',prevSpacePos+1); long long distance=atoll(line.substr(prevSpacePos+1,spacePos).c_str()); currentTransform.push_back({source,distance,dest}); }else{ //No-op, skip non-number line. /*for(Seed&seed:seeds){ std::cout<&transformList:transforms){ for(Transform&transform:transformList){ if(seedNumb>=transform.source&&seedNumb