MathLabs

Problem 5

Turbo the snail is in the top row of a grid with 2024 rows and 2023 columns and wants to get to the bottom row. However, there are 2022 hidden monsters, one in every row except the first and last, with no two monsters in the same column. Turbo makes a series of attempts to go from the first row to the last row. On each attempt, he chooses to start on any cell in the first row, then repeatedly moves to an orthogonal neighbor. (He is allowed to return to a previously visited cell.) If Turbo reaches a cell with a monster, his attempt ends and he is transported back to the first row to start a new attempt. The monsters do not move between attempts, and Turbo remembers whether or not each cell he has visited contains a monster. If he reaches any cell in the last row, his attempt ends and Turbo wins. Find the smallest integer nn such that Turbo has a strategy which guarantees being able to reach the bottom row in at most nn attempts, regardless of how the monsters are placed.
Step 4 of 5: Case where M1 is on the edge
In plain words

If the first monster is against a wall, Turbo instead follows a diagonal staircase moving away from that wall; if a second monster interrupts the staircase, the safe portion already walked, together with the known columns of both monsters, lets Turbo build a route around both on the next try.

M1 on the edge  ⟹  staircase, then a third attempt around M2M_1 \text{ on the edge} \implies \text{staircase, then a third attempt around } M_2
Detailed analysis

Assume M1=(2,1)M_1=(2,1); the right-edge case is its mirror image. On attempt 2 enter row 2 at (2,2)(2,2), visit (2,3)(2,3) and return to (2,2)(2,2), then descend to (3,2)(3,2). In each row r=3,…,s−2r=3,\ldots,s-2, enter at (r,r−1)(r,r-1), visit (r,r)(r,r) and (r,r+1)(r,r+1), return to (r,r)(r,r), and descend to (r+1,r)(r+1,r). In the last monster row enter (s−1,s−2)(s-1,s-2), visit (s−1,s−1)(s-1,s-1), and then descend to the goal row. This is the staircase. If it is clear, Turbo wins on attempt 2. If it first meets M2M_2 at a downward entry (r,r−1)(r,r-1), then the already visited shoulder (r−1,r)(r-1,r) is safe; on attempt 3 follow the safe prefix to that shoulder, enter row rr at (r,r)(r,r), move west to column 1, and descend column 1. If M2M_2 is met on one of the horizontal steps instead, the cell immediately to its west is safe; reproduce the prefix to that cell, move west to column 1 in row rr, and descend. In either subcase, every other cell of row rr is safe because it contains the unique monster M2M_2 of that row, and column 1 is safe below row 2 because it already contains M1M_1. Thus the third path reaches the goal. This gives a completely specified strategy in at most 3 attempts.