- Home /

# Need Equation to flip 5x5 Matrix

On a wing and a prayer here ... does anyone know of a way to flip the values below?

An equation where 2 becomes 14, 3 becomes 13, 4 becomes 12, etc?

So, want to switch row 0 with row 4, and row 1 with row 3?

If so, that's super-easy. Just a single loop and swap A[i][0] with A[i][4].

hmm cool, I was hoping for something more elegant but that should work. Though I think I am going to just make a huge Switch/Case instead of 4 arrays. Thanks tho!

If you can handle the programming, a 2-dimensional array is much better. In C# something like `int[,] = new int[5,5];`

. Do you just have 25 variables, now?

With large ifs/switches it's so easy to have one tiny mistake -- position 2,4 swaps with 2,2 instead of 2,1 -- which doesn't show up in testing. Loops over arrays either break big-time, or work perfectly. Plus much easier to go to a 6x6 board.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Circular motion via the mathematical circle equation? 4 Answers

How to get translation from matrix? 1 Answer

how inverse and transpose 3 * 3 matrix in unity?? 0 Answers

RigidBody 2D x velocity function 1 Answer

Destroying an object in a matrix 1 Answer