parent
233addac52
commit
d1863f213d
3 changed files with 35 additions and 3 deletions
@ -1,9 +1,31 @@ |
|||||||
#include "Day15.h" |
#include "Day15.h" |
||||||
|
|
||||||
Result Day15::Task1() { |
Result Day15::Task1() { |
||||||
|
Set sensors; |
||||||
|
Set beacons; |
||||||
|
|
||||||
|
parseSystem(sensors, beacons); |
||||||
|
|
||||||
return Day::Task1(); |
return Day::Task1(); |
||||||
} |
} |
||||||
|
|
||||||
Result Day15::Task2() { |
Result Day15::Task2() { |
||||||
return Day::Task2(); |
return Day::Task2(); |
||||||
} |
} |
||||||
|
|
||||||
|
void Day15::parseSystem(Set &sensors, Set &beacons) { |
||||||
|
for (const string &line : input){ |
||||||
|
size_t xPos = line.find('x') + 2; |
||||||
|
size_t yPos = line.find('y') + 2; |
||||||
|
int64 sx = stoi(line.substr(xPos, line.find(',') - xPos)); |
||||||
|
int64 sy = stoi(line.substr(yPos, line.find(':') - yPos)); |
||||||
|
|
||||||
|
xPos = line.find("is at") + 8; |
||||||
|
yPos = line.find('y', xPos) + 2; |
||||||
|
int64 bx = stoi(line.substr(xPos, line.find(',', xPos) - xPos)); |
||||||
|
int64 by = stoi(line.substr(yPos)); |
||||||
|
|
||||||
|
sensors.insert({sx, sy}); |
||||||
|
beacons.insert({bx, by}); |
||||||
|
} |
||||||
|
} |
||||||
|
Loading…
Reference in new issue