I used brute force to solve this problem. The function ‘process’ just takes a cell and then finds if the condition is satisfied by adjacent cells. the if statements are for the boundary conditions.
I tried printing the matrix and finding the total walks manually and verified it with the output from my code.
But my submission is not accepted. Can anyone help me in finding whats wrong with my code?