#include "../../include/aoc.hpp" #include using namespace std; unordered_map m; const int smax = 70; void rec(icoord c, int score) { if (!m.contains(c)) { return; } int &s = m[c]; if (s != -1 && s <= score) { return; } s = score; score++; rec(c + icoord(1, 0), score); rec(c + icoord(-1, 0), score); rec(c + icoord(0, 1), score); rec(c + icoord(0, -1), score); } int main() { ios::sync_with_stdio(0); cin.tie(0); string line; bool inits[smax + 1][smax + 1] = {}; int i = 0; while (getline(cin, line) && !line.empty()) { // NOTE: found part 2 is just binary search on this number until you // stop getting -1 as output if (++i > 1024) { break; } istringstream l(line); int x, y; l >> x; l.ignore(); l >> y; inits[x][y] = true; } for (int x = 0; x <= smax; x++) { for (int y = 0; y <= smax; y++) { if (!inits[x][y]) { m[{x, y}] = -1; } } } rec({0, 0}, 0); cout << m[{smax, smax}] << '\n'; }