Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.25 KB

File metadata and controls

49 lines (33 loc) · 1.25 KB

Developer Test: Matrix Transposition

This test is designed to assess your ability to implement matrix transposition in Python.

Task

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.

Example

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]
]

Requirements

  • 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.

Unit Tests

A set of unit tests is provided in the file to verify the correctness of your implementation. Running the file runs the tests.

Instructions

  1. Clone this repository to your local machine.
  2. Implement the transpose_matrix function in the transpose_matrix.py file.
  3. Run the unit tests to validate your implementation.
  4. Once you are satisfied with your solution, submit your code for review.

Good luck!