-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
129 lines (124 loc) Β· 4.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package main
import (
"errors"
"fmt"
"os"
"github.com/alokmenghrajani/adventofcode2020/day01"
"github.com/alokmenghrajani/adventofcode2020/day02"
"github.com/alokmenghrajani/adventofcode2020/day03"
"github.com/alokmenghrajani/adventofcode2020/day04"
"github.com/alokmenghrajani/adventofcode2020/day05"
"github.com/alokmenghrajani/adventofcode2020/day06"
"github.com/alokmenghrajani/adventofcode2020/day07"
"github.com/alokmenghrajani/adventofcode2020/day08"
"github.com/alokmenghrajani/adventofcode2020/day09"
"github.com/alokmenghrajani/adventofcode2020/day10"
"github.com/alokmenghrajani/adventofcode2020/day11"
"github.com/alokmenghrajani/adventofcode2020/day12"
"github.com/alokmenghrajani/adventofcode2020/day13"
"github.com/alokmenghrajani/adventofcode2020/day14"
"github.com/alokmenghrajani/adventofcode2020/day15"
"github.com/alokmenghrajani/adventofcode2020/day16"
"github.com/alokmenghrajani/adventofcode2020/day17"
"github.com/alokmenghrajani/adventofcode2020/day18"
"github.com/alokmenghrajani/adventofcode2020/day19"
"github.com/alokmenghrajani/adventofcode2020/day20"
"github.com/alokmenghrajani/adventofcode2020/day21"
"github.com/alokmenghrajani/adventofcode2020/day22"
"github.com/alokmenghrajani/adventofcode2020/day23"
"github.com/alokmenghrajani/adventofcode2020/day24"
"github.com/alokmenghrajani/adventofcode2020/day25"
"github.com/alokmenghrajani/adventofcode2020/utils"
)
// Usage: go run main.go <NN>
// assumes input is in day<NN>/input.txt
func main() {
d := day()
fmt.Printf("Running day %02d\n", d)
switch d {
case 1:
fmt.Printf("part 1: %d\n", day01.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day01.Part2(utils.Readfile(d)))
case 2:
fmt.Printf("part 1: %d\n", day02.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day02.Part2(utils.Readfile(d)))
case 3:
fmt.Printf("part 1: %d\n", day03.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day03.Part2(utils.Readfile(d)))
case 4:
fmt.Printf("part 1: %d\n", day04.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day04.Part2(utils.Readfile(d)))
case 5:
fmt.Printf("part 1: %d\n", day05.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day05.Part2(utils.Readfile(d)))
case 6:
fmt.Printf("part 1: %d\n", day06.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day06.Part2(utils.Readfile(d)))
case 7:
fmt.Printf("part 1: %d\n", day07.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day07.Part2(utils.Readfile(d)))
case 8:
fmt.Printf("part 1: %d\n", day08.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day08.Part2(utils.Readfile(d)))
case 9:
fmt.Printf("part 1: %d\n", day09.Part1(25, utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day09.Part2(25, utils.Readfile(d)))
case 10:
fmt.Printf("part 1: %d\n", day10.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day10.Part2(utils.Readfile(d)))
case 11:
fmt.Printf("part 1: %d\n", day11.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day11.Part2(utils.Readfile(d)))
case 12:
fmt.Printf("part 1: %d\n", day12.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day12.Part2(utils.Readfile(d)))
case 13:
fmt.Printf("part 1: %d\n", day13.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day13.Part2(utils.Readfile(d)))
case 14:
fmt.Printf("part 1: %d\n", day14.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day14.Part2(utils.Readfile(d)))
case 15:
fmt.Printf("part 1: %d\n", day15.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day15.Part2(utils.Readfile(d)))
case 16:
fmt.Printf("part 1: %d\n", day16.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day16.Part2(utils.Readfile(d)))
case 17:
fmt.Printf("part 1: %d\n", day17.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day17.Part2(utils.Readfile(d)))
case 18:
fmt.Printf("part 1: %d\n", day18.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day18.Part2(utils.Readfile(d)))
case 19:
fmt.Printf("part 1: %d\n", day19.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day19.Part2(utils.Readfile(d)))
case 20:
fmt.Printf("part 1: %d\n", day20.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day20.Part2(utils.Readfile(d)))
case 21:
fmt.Printf("part 1: %d\n", day21.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %s\n", day21.Part2(utils.Readfile(d)))
case 22:
fmt.Printf("part 1: %d\n", day22.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day22.Part2(utils.Readfile(d)))
case 23:
fmt.Printf("part 1: %s\n", day23.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day23.Part2(utils.Readfile(d)))
case 24:
fmt.Printf("part 1: %d\n", day24.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day24.Part2(utils.Readfile(d)))
case 25:
fmt.Printf("part 1: %d\n", day25.Part1(utils.Readfile(d)))
default:
panic(errors.New(fmt.Sprintf("no such day: %d", d)))
}
}
// Reads day from os.Args.
func day() int {
if len(os.Args) == 1 {
return 25
}
day := utils.Atoi(os.Args[1], -1)
return day
}