tourner la matrice de 90 degrés dans le sens des aiguilles d'une montre javascript
// transpone
const transpose = matrix => {
for (let row = 0; row < matrix.length; row++) {
for (let column = 0; column < row; column++) {
let temp = matrix[row][column]
matrix[row][column] = matrix[column][row]
matrix[column][row] = temp
}
}
return matrix;
}
// reverse
const reverse = matrix => matrix.map(row => row.reverse());
// rotate
const rotate = matrix => transpose(reverse(matrix));
code fighter