Skip to content
Advertisement

Tag: matrix

PHP rotate matrix counter-clockwise

I am solving a larger problem and at one step I need to rotate a 2D array counter-clockwise. So if I have this matrix: After the rotation it will be: I have found a solution to rotate it clockwise: The thing is that this has to work even when a is uni-dimensional or has only one element. So, 1 2

Advertisement