chore: add day13
This commit is contained in:
parent
eb758ab41d
commit
aeb0b8752a
|
@ -1,6 +0,0 @@
|
||||||
???.### 1,1,3
|
|
||||||
.??..??...?##. 1,1,3
|
|
||||||
?#?#?#?#?#?#?#? 1,3,1,6
|
|
||||||
????.#...#... 4,1,1
|
|
||||||
????.######..#####. 1,6,5
|
|
||||||
?###???????? 3,2,1
|
|
16
tools.go
16
tools.go
|
@ -250,3 +250,19 @@ func ABS(i int) int {
|
||||||
}
|
}
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Transpose[T any](matrix [][]T) [][]T {
|
||||||
|
rows, cols := len(matrix), len(matrix[0])
|
||||||
|
|
||||||
|
m := make([][]T, cols)
|
||||||
|
for i := range m {
|
||||||
|
m[i] = make([]T, rows)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < cols; i++ {
|
||||||
|
for j := 0; j < rows; j++ {
|
||||||
|
m[i][j] = matrix[j][i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user