Question: python essment Write a function valid_path(n, path) that takes in the size of the grid and a travel path, and returns True if the path

python
essment Write a function valid_path(n, path) that takes in the size of the grid and a travel path, and returns True if the path is valid and False if the path is invalid. A path is only valid when Eve ends at the goal coordinate (N-1, N - 1) and the path conists of only legal moves between coordinates. Remember that coordinates must be inside the grid and legal moves are 1 unit: Right (East), Down (South), Diagonal-Right- Down (South-East). The parameters to this function are as follows: Nis the dimension of the grid. For example, if N = 2, then the size of the grid is 2 x 2 with a goal at coordinate (1,1). path is a list of coordinates represented in tuples, starting with (0, 0). Input Assumptions: You can assume that the input arguments are syntactically correct given the definitions, and will always be non-empty. The path will always begin at the entrance coordinate (0,0), but it may not necessarily end at the goal node. Here are example calls to your function: valid_path(2, [(0, 0), (1, 1)]) >>> True valid_path(4, [(0,0),(0,1),(0,2),(1,2),(2,3),(3,3)])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
