Converted matrix_transpose.py into a module
This commit is contained in:
parent
28e362f63f
commit
12ab1b9711
@ -13,9 +13,12 @@ Example:
|
||||
... ]
|
||||
>>> matrix_transpose(matrix)
|
||||
[[1, 4], [2, 5], [3, 6]]
|
||||
|
||||
NOTE: If you import the matrix_transpose module into your project, call it with matrix_transpose.transpose(M).
|
||||
|
||||
"""
|
||||
|
||||
def matrix_transpose(M) -> List[List]:
|
||||
def transpose(M) -> List[List]:
|
||||
row = []
|
||||
T = []
|
||||
mcols = len(M[0])
|
||||
@ -27,15 +30,3 @@ def matrix_transpose(M) -> List[List]:
|
||||
row = []
|
||||
return T
|
||||
|
||||
matrix = [
|
||||
[1,2,3,0],
|
||||
[4,5,6,1],
|
||||
[7,8,9,2],
|
||||
[1,2,3,4],
|
||||
[4,5,6,7]
|
||||
]
|
||||
|
||||
print(matrix_transpose(matrix))
|
||||
|
||||
# Output
|
||||
# [[1, 4, 7, 1, 4], [2, 5, 8, 2, 5], [3, 6, 9, 3, 6], [0, 1, 2, 4, 7]]
|
||||
Loading…
Reference in New Issue
Block a user