Question: Python code!! (Recursion) Consider a robot in a mXn grid who is only capable of moving right or down in the grid (can't move left,

Python code!!

Python code!! (Recursion) Consider a robot in a mXn grid who is

(Recursion) Consider a robot in a mXn grid who is only capable of moving right or down in the grid (can't move left, up or diagonal). The robot starts at the top left corner, (0,0), and is supposed to reach to the bottom right corner: (m-1,n-1). Some of the cells in the grid are blocked and the robot is not allowed to visit those cells. Write a function numPaths that takes the grid length and width (i.e., m, n) and the list of the blocked cells (blocks) as argument and returns the number of different paths the robot can take from 3. numPaths (m,n,blocks)-10% the start to the end. Give and answer using recursion. (A correct solution without recursion will be worth half the points.) start en The blocked cells are represented as a list of (x, y) pairs where x is the row and y is column where the blocked cell is located. For example, the 2x2 grid has a blocked cell at (2,1). There is only one way for the robot to move from the start to the goal. For the 3x3 grid, the robot has 3 different paths. numPaths (2,2,(2,1)1) returns1 numPaths (3,3,t (2,3)1) returns 3 numPaths (4,3,[ (2,2)]) returns 4 numPaths (10,3,1 (2,2),(7,1)1) returns 27 You can start with the following code def numPaths (m, n,blocks) &Write your code here def testnumPaths ) #write your code here; see the sample test function on page#4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!