]>
Commit | Line | Data |
---|---|---|
0e27f67c SW |
1 | package main |
2 | ||
3 | import "fmt" | |
4 | import "os" | |
5 | import "strconv" | |
6 | ||
7 | const HOLE = 0 | |
8 | const BOARD_SIZE = 16 | |
9 | ||
10 | type Space int8 | |
11 | type Board [BOARD_SIZE]Space | |
12 | ||
13 | func read_board_from_strings(in []string) (*Board, error) { | |
14 | if len(in) != BOARD_SIZE { | |
15 | return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE) | |
16 | } | |
17 | var b Board | |
18 | for i, s := range in { | |
19 | num, err := strconv.Atoi(s) | |
20 | b[i] = Space(num) | |
21 | if err != nil { | |
22 | return nil, err | |
23 | } | |
24 | } | |
25 | return &b, nil | |
26 | } | |
27 | ||
28 | func main() { | |
29 | start, err := read_board_from_strings(os.Args[1:]) | |
30 | if err != nil { | |
31 | panic(err) | |
32 | } | |
33 | fmt.Println(start) | |
34 | } |