For example I have a matrix:
0 1 2 3 4
[0 X X X X X ]
[1 X X N X X ]
[2 X X X X X ]
[3 X X X X X ]
[4 X X X X X ]
I need to move value "N" to the left, right, up or down. "N" current position is 1 2.
for e.g. I have a movement: U which means up. How should I move the value "N" to position 0 2?
If you store this in multidimensional array in your case 2- dimensional. Just find current indices where N is located insert X there and insert N inside +1 or -1 indices depending on your operation. Clear console and redisplay matrix.