diff options
Diffstat (limited to 'src/2022/day9/aoc.cpp')
-rw-r--r-- | src/2022/day9/aoc.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/2022/day9/aoc.cpp b/src/2022/day9/aoc.cpp index 2748141..94e5a01 100644 --- a/src/2022/day9/aoc.cpp +++ b/src/2022/day9/aoc.cpp @@ -101,7 +101,13 @@ struct arena { void follow(Co& t, Co& h) { int dy = h.y - t.y; int dx = h.x - t.x; - printf("(%d,%d) -> (%d,%d) %d %d\n", t.x, t.y, h.x, h.y, dx, dy); + // printf("(%d,%d) -> (%d,%d) %d %d\n", t.x, t.y, h.x, h.y, dx, dy); + if (std::abs(dy) == 2 && std::abs(dx) == 2) { + t.x += dx / 2; + t.y += dy / 2; + return; + } + if (dy == 2) { t.y += 1; t.x += dx; @@ -183,7 +189,7 @@ std::pair<int,int> day9(line_view file) { an.reset(); an.travel_tails(ms); int m2 = an.moves(); - return {m1, m2}; + return {m1, m2 + 1}; } } |