AlgoFrames

Neighbors of a cell

Warm-up · Trace the algorithm · about 4 min

In this grid, the dark cells are walls. A neighbor is an open cell directly above, right, below or left of the marked cell. Click every neighbor of the marked cell.

Example 1

Input:

{"rows":4,"cols":5,"walls":[[1,3],[2,2]],"cell":[2,3]}

Output:

["G/cell:2,4","G/cell:3,3"]

Up and left are walls.

Constraints

  • Only the four side-by-side cells count
  • Walls and cells outside the grid are not neighbors

Learn the idea first: Implicit graphs: grids, states and puzzles, a visual lesson.

More Implicit graphs: grids, states and puzzles problems