|
|
@ -6,13 +6,14 @@ import (
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const alpha = "abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ" // 无 'I' 的alpha
|
|
|
|
const alpha = "abcdefghjklmnopqrstuvwxyz" // 无 'I' 的alpha
|
|
|
|
|
|
|
|
const alphaUpper = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
|
|
|
|
|
|
|
|
|
|
|
|
func Point(x, y int) string {
|
|
|
|
func Point(x, y int) string {
|
|
|
|
if x < 0 || x >= 50 || y < 0 || y >= 50 {
|
|
|
|
if x < 0 || x >= 25 || y < 0 || y >= 25 {
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("%s%d", byteToString(alpha[x]), y+1)
|
|
|
|
return fmt.Sprintf("%s%d", byteToString(alphaUpper[x]), y+1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func byteToString(b byte) string {
|
|
|
|
func byteToString(b byte) string {
|
|
|
@ -20,12 +21,15 @@ func byteToString(b byte) string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ParsePoint(pos string) (x, y int) {
|
|
|
|
func ParsePoint(pos string) (x, y int) {
|
|
|
|
x = byteToIndex(pos[0])
|
|
|
|
x = byteToIndex(alpha, pos[0])
|
|
|
|
|
|
|
|
if x == -1 {
|
|
|
|
|
|
|
|
x = byteToIndex(alphaUpper, pos[0])
|
|
|
|
|
|
|
|
}
|
|
|
|
y, _ = nmath.Int(pos[1:])
|
|
|
|
y, _ = nmath.Int(pos[1:])
|
|
|
|
y = y - 1
|
|
|
|
y = y - 1
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func byteToIndex(b byte) int {
|
|
|
|
func byteToIndex(str string, b byte) int {
|
|
|
|
return strings.Index(alpha, string([]byte{b}))
|
|
|
|
return strings.Index(str, string([]byte{b}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|