This test is designed to assess your ability to implement matrix transposition in Python.
Implement a Python function transpose_matrix(matrix)
that takes a 2D matrix as input and returns the transposed matrix. The transposed matrix should have its rows converted to columns and columns converted to rows.
For example, given the following input matrix:
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
The expected output would be:
transposed_matrix = [
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]
- Implement the
transpose_matrix
function. - The function should handle matrices of arbitrary sizes (not necessarily square matrices).
- Do not use any built-in functions or external libraries that directly solve this task.
A set of unit tests is provided in the file to verify the correctness of your implementation. Running the file runs the tests.
- Clone this repository to your local machine.
- Implement the
transpose_matrix
function in thetranspose_matrix.py
file. - Run the unit tests to validate your implementation.
- Once you are satisfied with your solution, submit your code for review.
Good luck!