forked from king-11/bingo-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (38 loc) · 798 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"log"
"os"
"github.com/king-11/bingo/data"
"github.com/king-11/bingo/play"
"github.com/king-11/bingo/reader"
)
func logError(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
filename := os.Args[1]
winner := true
f, err := os.Open(filename)
logError(err)
defer f.Close()
scanner := reader.GetScanner(f)
order, err := reader.ReadOrder(scanner)
logError(err)
boards := make([]*data.Board, 0)
for scanner.Scan() {
board, err := reader.ReadBoard(scanner)
logError(err)
boards = append(boards, board)
}
if err := scanner.Err(); err != nil {
logError(err)
}
if winner {
fmt.Printf("Winner value is %d", play.FindWinner(order, boards))
} else {
fmt.Printf("Loser value is %d", play.FindLastBoard(order, boards))
}
}