#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 = 8; Run runInput=FILE2; std::map>nodes; std::string instructions; struct Node{ std::string val; std::string startingNode; }; std::vector currentNodes; int instructionIndex=0; void doStuff2(){ while(true){ //lines is accessible as a global. bool firstLine=true; for(int lineNumb=0;std::string&line:lines){ if(lineNumb==0){ instructions=line; }else if(lineNumb>=2){ std::string node=line.substr(0,3); nodes[node]={line.substr(line.find('(')+1,3),line.substr(line.find(')')-3,3)}; if(node[2]=='A'){ currentNodes.push_back({node,node}); } } lineNumb++; } long long step=0; bool notAtZ=true; while(notAtZ){ notAtZ=false; for(auto&[val,startingNode]:currentNodes){ char currentInstruction=instructions[instructionIndex]; if(currentInstruction=='R'){ val=nodes[val].second; }else{ val=nodes[val].first; } if(val[2]!='Z'){ notAtZ=true; } } instructionIndex=(instructionIndex+1)%instructions.length(); step++; } std::cout<=2){ nodes[line.substr(0,3)]={line.substr(line.find('(')+1,3),line.substr(line.find(')')-3,3)}; } lineNumb++; } int step=0; while(currentNode!="ZZZ"){ char currentInstruction=instructions[instructionIndex]; if(currentInstruction=='R'){ currentNode=nodes[currentNode].second; }else{ currentNode=nodes[currentNode].first; } instructionIndex=(instructionIndex+1)%instructions.length(); step++; } std::cout<