Simple open grid
Input
shortest_path([[0,0],[0,0]], (0,0), (1,1))
Output
2
From (0,0) to (1,1) you need two moves: right+down or down+right.
Full lesson preview
Compute the minimum number of moves from start to end in a 2D grid with obstacles using BFS.
Problem statement
Task
Examples
Input
shortest_path([[0,0],[0,0]], (0,0), (1,1))
Output
2
From (0,0) to (1,1) you need two moves: right+down or down+right.
Input format
Output format
Constraints
Samples
Input
shortest_path([[0,0,0],[1,1,0],[0,0,0]], (0,0), (2,2))
Output
4
A path exists around the blocked cells: (0,0)->(0,1)->(0,2)->(1,2)->(2,2) with 4 moves.