func convert(s string, numRows int) string { if numRows <= 1 { return s } m := 2*numRows - 2 ans := "" right := len(s) for raw := 0; raw < numRows; raw++ { i := 0 for ; i*m-raw < right || i*m+raw < right; i++ { pos := i * m if pos-raw >= 0 && raw != 0 && raw+1 != numRows { ans += string(s[pos-raw]) } if pos+raw < right { ans += string(s[pos+raw]) } } } return ans }