-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (43 loc) · 1015 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"
"sort"
)
type Task func(string) (string, error)
func main() {
tasks := map[int][]Task{
1: {AOC2022011, AOC2022012},
2: {AOC2022021, AOC2022022},
3: {AOC2022031, AOC2022032},
4: {AOC2022041, AOC2022042},
5: {AOC2022051, AOC2022052},
6: {AOC2022061, AOC2022062},
7: {AOC2022071, AOC2022072},
8: {AOC2022081, AOC2022082},
9: {AOC2022091, AOC2022092},
10: {AOC2022101, AOC2022102},
12: {AOC2022121, AOC2022122},
14: {AOC2022141, AOC2022142},
15: {AOC2022151, AOC2022152},
}
days := []int{}
for day := range tasks {
days = append(days, day)
}
sort.Ints(days)
for _, day := range days {
input, err := os.ReadFile(fmt.Sprintf("input/2022%02d", day))
if err != nil {
log.Fatalf("can't open input: %v", err)
}
for i, task := range tasks[day] {
res, err := task(string(input))
if err != nil {
log.Fatalf("error in Task %d/%d: %v", day, i+1, err)
}
log.Printf("AOC2022 %02d/%d: %s", day, i+1, res)
}
}
}