Implement 3x3 matrix transforms and rotation
Problem Description
You are tasked with implementing a set of matrix transformation operations for a 3x3 matrix using Python. For each operation, you must provide example inputs and their corresponding resulting matrices.
The required operations are:
- Transpose In-Place: Modify the matrix such that its rows become columns and its columns become rows, without using additional memory proportional to the matrix size.
- Swap Rows and Columns: Implement functions to swap any two specified rows and any two specified columns within the matrix.
- Reverse Column and All Rows: Implement functions to reverse the elements of a specified column and to reverse the elements of all rows in the matrix.
- Rotate 90 Degrees Clockwise: Rotate the entire matrix 90 degrees clockwise.
AI interview prep
Core dilemma
Achieving correct and efficient in-place matrix transformations while maintaining code clarity and handling edge cases for a fixed-size matrix.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement 3x3 matrix transforms and rotation
Problem Description
You are tasked with implementing a set of matrix transformation operations for a 3x3 matrix using Python. For each operation, you must provide example inputs and their corresponding resulting matrices.
The required operations are:
- Transpose In-Place: Modify the matrix such that its rows become columns and its columns become rows, without using additional memory proportional to the matrix size.
- Swap Rows and Columns: Implement functions to swap any two specified rows and any two specified columns within the matrix.
- Reverse Column and All Rows: Implement functions to reverse the elements of a specified column and to reverse the elements of all rows in the matrix.
- Rotate 90 Degrees Clockwise: Rotate the entire matrix 90 degrees clockwise.