sober-bishop/main.go

41 lines
560 B
Go

package main
import "fmt"
var (
// 4x4 board with node counts
board = map[int]int{
10: 2, 11: 3, 12: 3, 13: 3,
20: 1, 21: 4, 22: 5, 23: 9,
30: 0, 31: 2, 32: 2, 33: 4,
40: 0, 41: 1, 42: 3, 43: 0,
}
)
func main() {
q := make(chan int, 4)
// board[p]
p := 22
// walk and find nodes
if board[p-11] != 0 { // NW
q <- (p - 11)
}
if board[p-9] != 0 { // NE
q <- (p - 9)
}
if board[p+9] != 0 { // SW
q <- (p + 9)
}
if board[p+11] != 0 { // SE
q <- (p + 11)
}
close(q)
// Get valid nodes
for n := range q {
fmt.Println(n)
}
}