@@ -0,0 +1,1371 @@
+%22%22%22%0AAuthor: MrDupin%0ACreated At: 25th August 2017%0A%22%22%22%0Aimport inspect%0A%0A#Path(i, j) = min(Path(i-1, j), Path(i, j-1) + Matrix(i, j)%0A%0A%0Adef calculate_path(i, j, matrix, s):%0A    if(s%5Bi%5D%5Bj%5D %3E 0):%0A        #We have already calculated solution for i,j; return it.%0A        return s%5Bi%5D%5Bj%5D%0A%0A    m1 = calculate_path(i-1, j, matrix, s) + matrix%5Bi%5D%5Bj%5D #Optimal solution for i-1, j (top)%0A    m2 = calculate_path(i, j-1, matrix, s) + matrix%5Bi%5D%5Bj%5D #Optimal solution for i, j-1 (left)%0A%0A    #Store and return the optimal (minimum) solution%0A    if(m1 %3C m2):%0A        s%5Bi%5D%5Bj%5D = m1%0A        return m1%0A    else:%0A        s%5Bi%5D%5Bj%5D = m2%0A        return m2%0A%0A%0Adef find_path(matrix):%0A    l = len(matrix);%0A    #Initialize solution array.%0A    #A node of i, j in solution has an equivalent node of i, j in matrix%0A    s = %5B%5B0 for i in range(l)%5D for j in range(l)%5D;%0A%0A    #Initialize first node as its matrix equivalent%0A    s%5B0%5D%5B0%5D = matrix%5B0%5D%5B0%5D%0A%0A    #Initialize first column as the matrix equivalent + the above solution%0A    for i in range(1, l):%0A        s%5Bi%5D%5B0%5D = matrix%5Bi%5D%5B0%5D + s%5Bi-1%5D%5B0%5D%0A%0A    #Initialize first row as the matrix equivalent + the left solution%0A    for j in range(1, l):%0A        s%5B0%5D%5Bj%5D = matrix%5B0%5D%5Bj%5D + s%5B0%5D%5Bj-1%5D%0A%0A    return calculate_path(l-1, l-1, matrix, s)%0A%0A%0Adef get_code():%0A    %22%22%22%0A    returns the code for the min cost path function%0A    %22%22%22%0A    return inspect.getsource(calculate_path)%0A

Create min_cost_path.py