9 const BOARD_SIZE = BOARD_DIM * BOARD_DIM
12 type Board [BOARD_SIZE]Space
21 func read_board_from_strings(in []string) (*Board, error) {
22 if len(in) != BOARD_SIZE {
23 return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
26 for i, s := range in {
27 num, err := strconv.Atoi(s)
36 func adjacent_spaces(s Space) []Space {
37 if s < 0 || s >= BOARD_SIZE {
38 panic("Invalid space")
42 adjacent = append(adjacent, s+UP)
44 if s < BOARD_SIZE-BOARD_DIM {
45 adjacent = append(adjacent, s+DOWN)
48 adjacent = append(adjacent, s+LEFT)
50 if s%BOARD_DIM != BOARD_DIM-1 {
51 adjacent = append(adjacent, s+RIGHT)
57 start, err := read_board_from_strings(os.Args[1:])