Shortest path on a grid (BFS)
BFS on a grid: distances spread out in waves from S, and the first wave to touch E gives the shortest path.
GridS..#...., .#.#.##., .#...#.., .####.#., ......#E
Start at S with distance 0. Walls (█) block the way; moves go up, down, left and right.
- compare
- swap or write
- settled
Space play · ← → step · Home End jump · drag the strip to scrub