21 lines
364 B
Go
21 lines
364 B
Go
package q48
|
|
|
|
func rotateCell(matrix [][]int, x, y int) {
|
|
t := matrix[y][x]
|
|
for range 4 {
|
|
nextX, nextY := len(matrix)-1-y, x
|
|
matrix[nextY][nextX], t = t, matrix[nextY][nextX]
|
|
x, y = nextX, nextY
|
|
}
|
|
}
|
|
|
|
func rotate(matrix [][]int) {
|
|
w := len(matrix)
|
|
for y := range w / 2 {
|
|
for x := y; x < w-y-1; x++ {
|
|
rotateCell(matrix, x, y)
|
|
}
|
|
}
|
|
}
|
|
|
|
var _ = rotate
|