|
|
|
|
@ -161,13 +161,6 @@ func RotateClockwise[T any](slice [][]T) [][]T {
|
|
|
|
|
result[i] = make([]T, yl)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
r=0,c=0 -> c,width-1-r
|
|
|
|
|
r=0,c=1 -> c,width-1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r=1, c=0 -> c, width-1-r
|
|
|
|
|
*/
|
|
|
|
|
for row := 0; row < yl; row++ {
|
|
|
|
|
for col := 0; col < xl; col++ {
|
|
|
|
|
result[col][yl-1-row] = slice[row][col]
|
|
|
|
|
@ -210,3 +203,23 @@ func CloneMap[K comparable, V any](src map[K]V) map[K]V {
|
|
|
|
|
|
|
|
|
|
return dst
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsPrime[T int | uint | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64](n T) bool {
|
|
|
|
|
if n <= 1 {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if n <= 3 {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if n%2 == 0 || n%3 == 0 {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for i := T(5); i*i <= n; i += 6 {
|
|
|
|
|
if n%i == 0 || n%(i+2) == 0 {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|