Find a target in an unknown grid with a robot API

0
Remix

A robot sits somewhere in a grid you cannot see: you don't know its size, its walls or where you start. You can only call the robot's API: move forward (which reports whether it moved), turn left or right, and ask whether the current cell is the target. Write the search that stops as soon as the robot reaches the target.

Track visited cells in coordinates relative to the start, explore with depth-first search, and backtrack physically (turn around, move, turn back) after each branch. Follow-ups reported: return the path to the target, the time and space in terms of open cells, and which unit tests you would write for the navigation code.

MetaTechnical phone screenLast asked Nov 2025
No answer yet. Write the first one; the best answer gets endorsed.