W
W
WarriorKodeK2018-02-26 21:38:27
JavaScript
WarriorKodeK, 2018-02-26 21:38:27

How to flip a matrix?

Hello.
I have a matrix by type

[
    [1, 2, 3, 4, 5]
    [6, 7, 8, 9, 10]
    [11, 12, 13, 14, 15]
    [16, 17, 18, 19, 20]
    [21, 22, 23, 24, 25]
]

I need to flip it so that it looks like this:
[
    [1, 6, 11, 16, 21]
    [2, 7, 12, 17, 22]
    [3, 8, 13, 18, 23]
    [4, 9, 14, 19, 24]
    [5, 10, 15, 20, 25]
]

Matrix code - https://jsfiddle.net/354he3h4/
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2018-02-26
@WarriorKodeK

It's not a "flip", it's a transpose.
There are many solutions here: https://stackoverflow.com/questions/17428587/trans...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question