import "strconv"
const HOLE = 0
-const BOARD_SIZE = 16
+const BOARD_DIM = 4
+const BOARD_SIZE = BOARD_DIM * BOARD_DIM
type Space int8
type Board [BOARD_SIZE]Space
+const (
+ LEFT = -1
+ RIGHT = +1
+ UP = -BOARD_DIM
+ DOWN = +BOARD_DIM
+)
+
func read_board_from_strings(in []string) (*Board, error) {
if len(in) != BOARD_SIZE {
return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
return &b, nil
}
+func adjacent_spaces(s Space) []Space {
+ if s < 0 || s >= BOARD_SIZE {
+ panic("Invalid space")
+ }
+ var adjacent []Space
+ if s >= BOARD_DIM {
+ adjacent = append(adjacent, s+UP)
+ }
+ if s < BOARD_SIZE-BOARD_DIM {
+ adjacent = append(adjacent, s+DOWN)
+ }
+ if s%BOARD_DIM != 0 {
+ adjacent = append(adjacent, s+LEFT)
+ }
+ if s%BOARD_DIM != BOARD_DIM-1 {
+ adjacent = append(adjacent, s+RIGHT)
+ }
+ return adjacent
+}
+
func main() {
start, err := read_board_from_strings(os.Args[1:])
if err != nil {