matrix = [["a", "b", 1, "d", 1, "f"],
["b", "c", "d", "e","f", "a"],
[2, "d", "e", "f", "a", "b"],
["d", "e", "f", "a", "b", "c"],
["e", "f", "a", 3, "c", "d"],
["f", "a", "b", "c", "d", "e"]]
def matrix_ops(matrix):
# get m and n values for mxn matrix
m = len(matrix) #no of row
n = len(matrix[0]) #no of column
for i in range(m):
for j in range(n):
if matrix[i][j] == 1 and i==0:
matrix[i][j] = matrix[i+1][j]
if matrix[i][j] == 2 and i==2:
matrix[i][j] = matrix[i-1][j]
if matrix[i][j] == 3 and i==4:
matrix[i][j] = matrix[0][0] + matrix[0][n - 1] + matrix[m - 1][0] + matrix[m - 1][n - 1]
return matrix
new_matrix = matrix_ops(matrix)
for row in new_matrix:
print(row)
can someone please write a pseudo code for this.
Answers
Answered by
0
Similar questions