#include #define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" using namespace olc; struct Sensor{ vi2d pos; int radius; }; int main() { std::ifstream file("input"); std::vectorsensors; while (file.good()){ std::string line; std::getline(file,line); std::cout<0){ while (prevMarker!=std::string::npos){ std::string word=line.substr(prevMarker,marker-prevMarker); prevMarker=marker; marker=line.find(' ',prevMarker+1); if (word[1]=='x'){ if (sensorPos.x==-999){ sensorPos.x=std::atoi(word.substr(word.find('=')+1,word.find(',')-word.find('=')-1).c_str()); std::cout<<"Sensor X: "< Beacon Radius: "<0){ y+=1; } } if (std::abs(x)+std::abs(y)==s.radius){ vi2d targetPos={x,y}; if (x<0){ targetPos.x--; } if (x>0){ targetPos.x++; } if (x==0){ if (y>0){ targetPos.y++; } if (y<0){ targetPos.y--; } } if (s.pos.x+targetPos.x>=0&&s.pos.x+targetPos.x<=MAX_VAL&& s.pos.y+targetPos.y>=0&&s.pos.y+targetPos.y<=MAX_VAL){ vi2d target=s.pos+targetPos; for (Sensor ss:sensors){ if (std::abs(target.x-ss.pos.x)+std::abs(target.y-ss.pos.y)<=ss.radius){ goto next; } } std::cout<<"Target location found w/no signal! "<0){ targetPos.y++; } if (y==0){ if (x>0){ targetPos.x++; } if (x<0){ targetPos.x--; } } if (s.pos.x+targetPos.x>=0&&s.pos.x+targetPos.x<=MAX_VAL&& s.pos.y+targetPos.y>=0&&s.pos.y+targetPos.y<=MAX_VAL){ vi2d target=s.pos+targetPos; for (Sensor ss:sensors){ if (std::abs(target.x-ss.pos.x)+std::abs(target.y-ss.pos.y)<=ss.radius){ goto next; } } std::cout<<"Target location found w/no signal! "<0){ y-=1; } } if (std::abs(x)+std::abs(y)==s.radius){ vi2d targetPos={x,y}; if (x<0){ targetPos.x--; } if (x>0){ targetPos.x++; } if (x==0){ if (y>0){ targetPos.y++; } if (y<0){ targetPos.y--; } } if (s.pos.x+targetPos.x>=0&&s.pos.x+targetPos.x<=MAX_VAL&& s.pos.y+targetPos.y>=0&&s.pos.y+targetPos.y<=MAX_VAL){ vi2d target=s.pos+targetPos; for (Sensor ss:sensors){ if (std::abs(target.x-ss.pos.x)+std::abs(target.y-ss.pos.y)<=ss.radius){ goto next2; } } std::cout<<"Target location found w/no signal! "<0){ targetPos.y++; } if (y==0){ if (x>0){ targetPos.x++; } if (x<0){ targetPos.x--; } } if (s.pos.x+targetPos.x>=0&&s.pos.x+targetPos.x<=MAX_VAL&& s.pos.y+targetPos.y>=0&&s.pos.y+targetPos.y<=MAX_VAL){ vi2d target=s.pos+targetPos; for (Sensor ss:sensors){ if (std::abs(target.x-ss.pos.x)+std::abs(target.y-ss.pos.y)<=ss.radius){ goto next2; } } std::cout<<"Target location found w/no signal! "<