## Reverse & Shift Matrix Edge [Moderate]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | input1 = input().rstrip().split(" "); R = int(input1[0]); C = int(input1[1]); Matrix = []; for i in range(R): Matrix.append(input().rstrip().split(" ")); cMatrix = [[0 for i in range(C)] for j in range(R)]; for i in range(R): for j in range(C): cMatrix[i][j] = Matrix[i][j]; for i in range(len(Matrix)): for j in range(len(Matrix[0])): if (i == 0) or (i == R-1) or (j == 0) or (j == C-1): if (i==0) and (j!=(C-1)): Matrix[i][j+1] = cMatrix[i][j][::-1]; elif (j==0) and (i!=0): Matrix[i-1][j] = cMatrix[i][j][::-1]; elif (i==R-1) and (j!=0): Matrix[i][j-1] = cMatrix[i][j][::-1]; elif (i!=R-1) and (j==C-1): Matrix[i+1][j] = cMatrix[i][j][::-1]; for i in range(R): for j in range(C): if j != C-1: print(Matrix[i][j].lstrip("0"),end=" "); else: print(Matrix[i][j].lstrip("0")); |

Continue