M=[[0, 0, 0, 0, 0, 0, 0],[1, 0, 0, 1, 0, 0, 1],[2, 1, 0, 0, 1, 0, 0]]
def t(M,maxi,maxj,compare):
ma=0
maxi = maxj = 0
for i in range(0,3):
for j in range(0,7):
if M[i][j] < 2 and ma <= M[i][j]:
ma = M[i][j]
maxi = i
maxj = j
return(ma, maxi, maxj)
How can I write a recursive function such that it computes the M[i,j]
based on comparing conditions and does it till it reaches M[0,j]
(any j
).
I have tried to write a recursive function as of now :
def recursive_tracking(M,maxi,maxj):
for i in range(1,maxi):
for j in range(1,maxj):
M[i,j]=max(M[i-1,j],M[i,j-1],M[i-1,j-1])
return recursive tracking(M,i,j)
return i,j