← Questions

Move instructions for a robot that cannot see the maze

0
WaymoCodingLast asked Jan 2026

A coding interview question asked in Waymo's coding round, last asked Jan 2026. It tests search, grids and simulation.

You know a 2D maze of walls #, empty cells . and one exit E. A robot starts on some non-wall cell, possibly already on E, but you don't know which. It cannot see the maze or sense where it is; it just runs one instruction string you write in advance. Generate a string that leaves the robot on E after the whole string runs, wherever it started.

Interface

Unless you agree on a different interface with the interviewer, assume:

  • blind_instructions(maze: list[str]) -> str — a string over U D L R.

A move into a wall or off the grid leaves the robot where it is; otherwise it moves one cell. At least one valid string exists, and it need not be the shortest.

Example

blind_instructions(["E"])           ->  ""         # already there
blind_instructions(["..E"])         ->  "RR"
blind_instructions([".#E",
                    "..."])         ->  "DRRU"     # one valid answer
    # from (0,0): D (1,0), R (1,1), R (1,2), U (0,2)
    # from row 1: every start ends at (1,2), then U
    # from E (0,2): D (1,2), R R stay, U back to E

Constraints

  • At most 5 by 5, with at most 15 non-wall cells.
  • The robot must be on E at the end of the string, not just at some point during it.

Clarifying questions

  • What happens on a move into a wall?
  • Must the robot end on E, or is passing through it enough?
  • Is a shortest string required?
  • Can the robot start on E?

What a strong answer covers

  • The key reframe: track the set of cells the robot could be in. Each instruction maps that set to a new (never larger) set; the goal is the set {E}.
  • BFS over sets of possible positions (at most 2^15 states here), which finds a shortest string.
  • The scalable alternative: repeatedly pick two possible positions and append the shortest string that merges them (walls make them collide), until one remains, then the path from it to E; this gives a valid but longer string.
  • Why a robot on E must also end on E (it moves too), and a final check by simulating the string from every start.
  • Complexity of both approaches.

Follow-ups

  • The maze is 50 by 50. Which approach still works?
  • The robot can also sense when it bumps a wall.
  • Minimize the string length for larger mazes, or prove a bound on it.

Where it's asked

  • Waymo · Coding · Last asked Jan 202645 min · Usually two rounds; some give you the interviewer's buggy code to find and fix, some are read aloud with no skeleton

What it tests

search · grids · simulation

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding