xxxxxxxxxx
function rotate(matrix) {
return matrix[0].map((col, i) => matrix.map((row) => row[i]))
}
function rotateAntiClockwise(matrix) {
return matrix[0].map((col, i) => matrix.map((row) => row[i]).reverse())
}
xxxxxxxxxx
function arrayRotate(arr, reverse) {
if (reverse) arr.unshift(arr.pop());
else arr.push(arr.shift());
return arr;
}