Python Program for Maneuvering a cave (TCS Codevita) | PrepInsta
Maneuvering a Cave Problem
Maneuvering a Cave Problem is a 2-D array manipulation problem, which was asked in this year TCS CodeVita 2020 Season 9 coding competition, as a sample question. It is a pretty tough problem, but one can solve it if he has good command on data structures and dynamic programming. Here we have provided a Python Solution for this problem.
Cave Explorer Program in Python
The task is to count all the possible paths from top left to bottom right of a m x n matrix with the constraints that from each cell you can either move only to right or down.
- First line consists of T test cases. First line of every test case consists of N and M, denoting the number of rows and number of columns respectively.
- Single line output i.e count of all the possible paths from top left to bottom right of a m x n matrix..
def calculate(a, b): if a == 1 or b == 1: return 1 else: return calculate(a - 1, b) + calculate(a, b - 1) result =  test = int(input()) for i in range(test): a, b = map(int,input().split()) result.append(calculate(a, b)) for i in result: print(i,end=" ")
2 3 3 4 4 6 20