codeforces/669C_matrix.py
def calculate(self):
        """ Main calcualtion function of the class """

        matrix = []
        for r in range(self.n):
            row = [0] * self.m
            matrix.append(row)

        for cmd in reversed(self.nums):
            if cmd[0] == 3:
                matrix[cmd[1]-1][cmd[2]-1] = cmd[3]
            elif cmd[0] == 1:
                rep = matrix[cmd[1]-1][-1]
                for i in range(self.m):
                    matrix[cmd[1]-1][i], rep = rep, matrix[cmd[1]-1][i]
            elif cmd[0] == 2:
                rep = matrix[-1][cmd[1]-1]
                for i in range(self.n):
                    matrix[i][cmd[1]-1], rep = rep, matrix[i][cmd[1]-1]

        rows = [" ".join(map(str, row)) for row in matrix]
        result = "\n".join(rows)

        return str(result)
 Main calcualtion function of the class 
Main calcualtion function of the class
Main calcualtion function of the class
def calculate(self):
        matrix = []
        for r in range(self.n):
            row = [0] * self.m
            matrix.append(row)
        for cmd in reversed(self.nums):
            if cmd[0] == 3:
                matrix[cmd[1]-1][cmd[2]-1] = cmd[3]
            elif cmd[0] == 1:
                rep = matrix[cmd[1]-1][-1]
                for i in range(self.m):
                    matrix[cmd[1]-1][i], rep = rep, matrix[cmd[1]-1][i]
            elif cmd[0] == 2:
                rep = matrix[-1][cmd[1]-1]
                for i in range(self.n):
                    matrix[i][cmd[1]-1], rep = rep, matrix[i][cmd[1]-1]
        rows = [" ".join(map(str, row)) for row in matrix]
        result = "\n".join(rows)
        return str(result)
def calculate ( self ) : matrix = [ ] for r in range ( self . n ) : row = [ 0 ] * self . m matrix . append ( row ) for cmd in reversed ( self . nums ) : if cmd [ 0 ] == 3 : matrix [ cmd [ 1 ] - 1 ] [ cmd [ 2 ] - 1 ] = cmd [ 3 ] elif cmd [ 0 ] == 1 : rep = matrix [ cmd [ 1 ] - 1 ] [ - 1 ] for i in range ( self . m ) : matrix [ cmd [ 1 ] - 1 ] [ i ] , rep = rep , matrix [ cmd [ 1 ] - 1 ] [ i ] elif cmd [ 0 ] == 2 : rep = matrix [ - 1 ] [ cmd [ 1 ] - 1 ] for i in range ( self . n ) : matrix [ i ] [ cmd [ 1 ] - 1 ] , rep = rep , matrix [ i ] [ cmd [ 1 ] - 1 ] rows = [ " " . join ( map ( str , row ) ) for row in matrix ] result = "\n" . join ( rows ) return str ( result )
Main calcualtion function of the class
Main calcualtion function of the class
""" Main calcualtion function of the class """
self