add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent d798d5e8c9
commit 886b5e0a8e
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
34 changed files with 1164 additions and 0 deletions

View file

@ -0,0 +1,27 @@
package q6
import "strings"
func convert(s string, numRows int) string {
loopLen := numRows + max(0, numRows-2)
rows := make([][]byte, numRows)
for i := range numRows {
rows[i] = make([]byte, 0, (len(s)/loopLen+1)*2)
}
for i := range len(s) {
row := i % loopLen
if row >= numRows {
row = numRows - row%numRows - 2
}
rows[row] = append(rows[row], s[i])
}
b := strings.Builder{}
for i := range rows {
_, _ = b.Write(rows[i])
}
return b.String()
}
var _ = convert