#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" using namespace olc; enum Direction{ RIGHT, DOWN, LEFT, UP }; struct Instruction{ int number=-1; Direction turn; }; int main() { std::vector>map; std::vectorinstructions; std::vectorvisitedLocs; std::ifstream file("input"); while (file.good()){ std::string line; std::getline(file,line); if (line.length()>0){ if (line[0]=='.'||line[0]==' '||line[0]=='#'){ std::vectormapRow; for (int i=0;i='0'&&line[marker]<='9'){ acc+=line[marker++]; } instructions.push_back({std::atoi(acc.c_str())}); isNumber=false; } else { switch(line[marker++]){ case 'R':{ instructions.push_back({-1,Direction::RIGHT}); }break; case 'L':{ instructions.push_back({-1,Direction::LEFT}); }break; } isNumber=true; } } } } } for (int y=0;y0){ switch (facingDir){ case Direction::RIGHT:{ char tile=' '; vi2d targetPos={pos.x+1,pos.y}; if (pos.x+1>=map[pos.y].size()){ for (int i=0;i0;y--){ if (map[y].size()>pos.x){ if (map[y][pos.x]=='.'){ targetPos.y=y; break; }else if (map[y][pos.x]=='#'){ goto next; } } } } tile=map[targetPos.y][targetPos.x]; switch (tile){ case '.':{ pos=targetPos; visitedLocs.push_back(pos); }break; case '#':{ goto next; }break; case ' ':{ //Impossible when going right. }break; } }break; case Direction::DOWN:{ char tile=' '; vi2d targetPos={pos.x,pos.y+1}; if (pos.y+1>=map.size()||map[pos.y+1].size()<=pos.x||map[pos.y+1][pos.x]==' '){ for (int y=0;ypos.x){ if (map[y][pos.x]=='.'){ std::cout<<"Found a spot. ("<