Question: Python Q1)As the Grid Path problems we discussed in class, the problem here asks you to compute the number of unique paths between any two

Python Q1)As the Grid Path problems we discussed in class, the problem here asks you to compute the number of unique paths between any two arbitrary points(origin, destination) on a Cartesian grid. Below is an example of a 6x6 grid, with a point marking the locations at (0, 0) and (6, 6):

def gridPaths(originX, originY, destinationX, destinationY):

Complete the function gridPaths() to compute the number of unique paths on a grid between the two points located at (originX, originY) and (destinationX, destinationY). You can assume that destinationX originX and destinationY originY. The possible movements at each point is either right (one unit down the X-axis), or up (one unit up the Y-axis). No diagonal movements are allowed.

Extra Credit: 5 points(if you use recursive method)

Sample Input: gridPaths(1, 1, 3, 3)

Output: There are 6 unique paths.

1,1-1,2-1,3-2,3-3,3

1,1-1,2-2,2-2,3-3,3

1,1-1,2-2,2-3,2-3,3

1,1-2,1-2,2-2,3-3,3

1,1-2,1-2,2-3,2-3,3

1,1-2,1-3,1-3,2-3,3

Sample Input: gridPaths(1, 2, 3, 3)

Output: There are 3 unique paths

1,2-1,3-2,3-3,3

1,2-2,2-3,2-3,3

1,2-2,2-3,2-3,3

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!