human
Count all possible paths from top left to bottom right of a mXn matrix | Returns count of possible paths to reach cell at row number m and column number n from the topmost leftmost cell ( cell at 1 , 1 ).
Create a 2D table to store results of subproblems one - liner logic to take input for rows and columns mat = [ [ int ( input ( ) ) for x in range ( C ) ] for y in range ( R ) ].
Count of paths to reach any cell in first column is 1.
Count of paths to reach any cell in first column is 1.
Calculate count of paths for other cells in bottom - up manner using the recursive solution.
By uncommenting the last part the code calculates the total possible paths if the diagonal Movements are allowed.
Driver program to test above function"
How can the above be solved in Python?
assistant
#Here is code to count all possible paths from top left to bottom right of a mXn matrix and the other steps required.
 def numberOfPaths ( m , n ) :
	count = [ [ 0 for x in range ( n ) ] for y in range ( m ) ]
	for i in range ( m ) :
		count [ i ] [ 0 ] = 1 ;
	for j in range ( n ) :
		count [ 0 ] [ j ] = 1 ;
	for i in range ( 1 , m ) :
		for j in range ( 1 , n ) :
			count [ i ] [ j ] = count [ i - 1 ] [ j ] + count [ i ] [ j - 1 ]
	return count [ m - 1 ] [ n - 1 ]
m = 3
n = 3
print ( numberOfPaths ( m , n ) )