Rotate-Transform the Two-Dimensional Matrix

Published by Sinomede in

Create a function to rotate a two-dimensional matrix of N * N integer elements num times, where if num is positive, the rotation is clockwise, and if not, counterclockwise.

Examples

RotateTransform({
  {2, 4},
  {0, 0}
}, 1) ➞ {
  {0, 2},
  {0, 4}
}
RotateTransform({ 
  {2, 4},
  {0, 0}
}, -1) ➞ {
  {4, 0},
  {2, 0}
}

Notes

N/A

Watch a quick demo on how Edabit works.