add new solutions
This commit is contained in:
parent
d798d5e8c9
commit
886b5e0a8e
34 changed files with 1164 additions and 0 deletions
21
solutions/0/q48/solution.go
Normal file
21
solutions/0/q48/solution.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue