-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoc.go
More file actions
52 lines (48 loc) · 1.11 KB
/
aoc.go
File metadata and controls
52 lines (48 loc) · 1.11 KB
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
package main
import (
"adventofcode2018/day_1"
"adventofcode2018/day_10"
"adventofcode2018/day_11"
"adventofcode2018/day_12"
"adventofcode2018/day_2"
"adventofcode2018/day_3"
"adventofcode2018/day_4"
"adventofcode2018/day_5"
"adventofcode2018/day_6"
"adventofcode2018/day_7"
"adventofcode2018/day_8"
"adventofcode2018/day_9"
"fmt"
"os"
)
// aoc.go <day> <part>
func main() {
// these exported functions must all have the same return type!
days := map[string]func(part string, input string) (result string){
"day_1": day_1.Call,
"day_2": day_2.Call,
"day_3": day_3.Call,
"day_4": day_4.Call,
"day_5": day_5.Call,
"day_6": day_6.Call,
"day_7": day_7.Call,
"day_8": day_8.Call,
"day_9": day_9.Call,
"day_10": day_10.Call,
"day_11": day_11.Call,
"day_12": day_12.Call,
}
var day string
var part string
var input string
if len(os.Args) != 4 {
fmt.Println("Incorrect number of args: aoc.go <day> <part> <path/to/input.txt>")
} else {
day = os.Args[1]
part = os.Args[2]
input = os.Args[3]
f := "day_" + day
result := days[f](part, input)
fmt.Println("result:", result)
}
}