-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
69 lines (62 loc) · 1.72 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
// Copyright 2022 Loran Kloeze. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"os"
"github.com/lorankloeze/advent2022/day1"
"github.com/lorankloeze/advent2022/day10"
"github.com/lorankloeze/advent2022/day11"
"github.com/lorankloeze/advent2022/day2"
"github.com/lorankloeze/advent2022/day3"
"github.com/lorankloeze/advent2022/day4"
"github.com/lorankloeze/advent2022/day5"
"github.com/lorankloeze/advent2022/day6"
"github.com/lorankloeze/advent2022/day7"
"github.com/lorankloeze/advent2022/day8"
"github.com/lorankloeze/advent2022/day9"
)
func main() {
challenges := map[string]func(){
"day1-1": day1.PartOne,
"day1-2": day1.PartTwo,
"day2-1": day2.PartOne,
"day2-2": day2.PartTwo,
"day3-1": day3.PartOne,
"day3-2": day3.PartTwo,
"day4-1": day4.PartOne,
"day4-2": day4.PartTwo,
"day5-1": day5.PartOne,
"day5-2": day5.PartTwo,
"day6-1": day6.PartOne,
"day6-2": day6.PartTwo,
"day7-1": day7.PartOne,
"day7-2": day7.PartTwo,
"day8-1": day8.PartOne,
"day8-2": day8.PartTwo,
"day9-1": day9.PartOne,
"day9-2": day9.PartTwo,
"day10-1": day10.PartOne,
"day10-2": day10.PartTwo,
"day11-1": day11.PartOne,
"day11-2": day11.PartTwo,
}
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <challenge e.g. day1-1>\n", os.Args[0])
os.Exit(1)
}
err := runChallenge(os.Args[1], challenges)
if err != nil {
fmt.Fprintf(os.Stderr, "Error running challenge: %v\n", err)
os.Exit(1)
}
}
func runChallenge(challenge string, challenges map[string]func()) error {
if fn, ok := challenges[challenge]; ok {
fn()
return nil
} else {
return fmt.Errorf("challenge %q not found", challenge)
}
}