Array.rotate()

From ZCubes Wiki
Jump to navigation Jump to search


Array.rotate(NoOfRotations)

Rotate the matrix n times. Works on multidimensional matrices also.


[1,2,3].rotate(1)

[3, 1, 2]

MAGICSQUARE(3)

2 7 6
9 5 1
4 3 8

MAGICSQUARE(3).rotate(1)

9 2 7
4 5 6
3 8 1

MAGICSQUARE(3).rotate(2)

4 9 2
3 5 7
8 1 6