]> git.scottworley.com Git - slidingtile/blame - sliding_tile.go
Ignore the built binary
[slidingtile] / sliding_tile.go
CommitLineData
0e27f67c
SW
1package main
2
3import "fmt"
4import "os"
5import "strconv"
6
7const HOLE = 0
8const BOARD_SIZE = 16
9
10type Space int8
11type Board [BOARD_SIZE]Space
12
13func read_board_from_strings(in []string) (*Board, error) {
212a5629
SW
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
0e27f67c
SW
26}
27
28func main() {
212a5629
SW
29 start, err := read_board_from_strings(os.Args[1:])
30 if err != nil {
31 panic(err)
32 }
33 fmt.Println(start)
0e27f67c 34}