-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (56 loc) · 1.65 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"flag"
"fmt"
day01 "github.com/doniacld/adventofcode/puzzles/2020/01"
day02 "github.com/doniacld/adventofcode/puzzles/2020/02"
day03 "github.com/doniacld/adventofcode/puzzles/2020/03"
day04 "github.com/doniacld/adventofcode/puzzles/2020/04"
day05 "github.com/doniacld/adventofcode/puzzles/2020/05"
day06 "github.com/doniacld/adventofcode/puzzles/2020/06"
day09 "github.com/doniacld/adventofcode/puzzles/2020/09"
"github.com/doniacld/adventofcode/puzzles/solver"
"log"
)
const (
flagParamYear = "year"
flagParamDay = "day"
defaultYear = 2020
defaultDay = 01
minDay = 1
maxDay = 25
)
func main() {
// parse flags
year := flag.Int(flagParamYear, defaultYear, "give me a year")
day := flag.Int(flagParamDay, defaultDay, "give me a day")
flag.Parse()
if *year < 2020 {
log.Fatalf("Maybe one day, I will solve the previous years !")
}
if *day < minDay || *day > maxDay {
log.Fatalf("invalid given day: %q is out of the possible range [1-25]", *day)
}
var s solver.Solver
switch *day {
case 1:
s = day01.New("./puzzles/2020/01/input.txt")
case 2:
s = day02.New("./puzzles/2020/02/input.txt")
case 3:
s = day03.New("./puzzles/2020/03/input.txt", [][2]int{{1, 1}, {3, 1}, {5, 1}, {7, 1}, {1, 2}})
case 4:
s = day04.New("./puzzles/2020/04/input.txt")
case 5:
s = day05.New("./puzzles/2020/05/input.txt")
case 6:
s = day06.New("./puzzles/2020/06/input.txt")
case 9:
s = day09.New("./puzzles/2020/09/input.txt", 25)
}
out, err := s.Solve()
if err != nil {
log.Fatalf("Something wrong happened while computing day %d: %s", *day, err.Error())
}
fmt.Printf(">>>>>>>>>>>>>> %s <<<<<<<<<<<<<<<\n", out)
}