chain matrix multiplication using dynamic programming

`def mul(arr, n): m = [[0 for x in range(n)] for x in range(n)] for i in range(1, n): m[i][i] = 0 for L in range(2, n): for i in range(1, n - L + 1): j = i + L - 1 m[i][j] = sys.maxsize for k in range(i, j): q = m[i][k] + m[k + 1][j] + arr[i - 1] * arr[k] * arr[j] if q < m[i][j]: m[i][j] = q return m[1][n - 1]`