6 kyu

Matrix Transpose

69 of 7,919osuushi

Description:

Write a function that outputs the transpose of a matrix - a new matrix where the columns and rows of the original are swapped.

For example, the transpose of:

| 1 2 3 |
| 4 5 6 |

is

| 1 4 |
| 2 5 |
| 3 6 |

The input to your function will be an array of matrix rows. You can assume that each row has the same length, and that the height and width of the matrix are both positive.

Mathematics
Algebra
Matrix
Algorithms

More By Author:

Check out these other kata created by osuushi

Stats:

CreatedFeb 12, 2014
PublishedFeb 12, 2014
Warriors Trained11967
Total Skips243
Total Code Submissions19396
Total Times Completed7919
CoffeeScript Completions69
JavaScript Completions4331
Python Completions2743
Ruby Completions159
C Completions434
Groovy Completions34
Go Completions158
λ Calculus Completions11
Rust Completions131
OCaml Completions35
D Completions5
Scala Completions29
Crystal Completions8
Lua Completions11
Haskell Completions11
Total Stars177
% of votes with a positive feedback rating92% of 752
Total "Very Satisfied" Votes655
Total "Somewhat Satisfied" Votes80
Total "Not Satisfied" Votes17
Ad
Contributors
  • osuushi Avatar
  • jhoffner Avatar
  • suic Avatar
  • Chrono79 Avatar
  • JohanWiltink Avatar
  • user7657844 Avatar
  • rowcased Avatar
  • armandfardeau Avatar
  • monadius Avatar
  • trashy_incel Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • tobeannouncd Avatar
  • Insisted Avatar
  • KayleighWasTaken Avatar
  • metatable Avatar
Ad