mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-07 12:45:10 +02:00
added day15 solutions
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package util
|
||||
|
||||
const MaxSafeInt int = 1<<31 - 1
|
||||
@@ -16,3 +16,18 @@ func RotateGrid(grid [][]string) [][]string {
|
||||
}
|
||||
return rotated
|
||||
}
|
||||
|
||||
// RotateGridInts will transpose a 2D array of ints
|
||||
func RotateGridInts(grid [][]int) [][]int {
|
||||
rotated := make([][]int, len(grid[0]))
|
||||
for i := range rotated {
|
||||
rotated[i] = make([]int, len(grid))
|
||||
}
|
||||
|
||||
for i := 0; i < len(grid); i++ {
|
||||
for j := 0; j < len(grid[0]); j++ {
|
||||
rotated[len(grid[0])-1-j][i] = grid[i][j]
|
||||
}
|
||||
}
|
||||
return rotated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user