-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (55 loc) · 1.6 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
package main
import (
"fmt"
"strconv"
"strings"
"github.com/manifoldco/promptui"
"github.com/ozancaglar/advent-of-code-2023/day1"
"github.com/ozancaglar/advent-of-code-2023/day2"
"github.com/ozancaglar/advent-of-code-2023/day3"
"github.com/ozancaglar/advent-of-code-2023/day4"
"github.com/ozancaglar/advent-of-code-2023/day5"
"github.com/ozancaglar/advent-of-code-2023/day6"
"github.com/ozancaglar/advent-of-code-2023/day7"
"github.com/ozancaglar/advent-of-code-2023/day8"
)
type day struct {
Day string
Function func(filename string)
}
func main() {
days := []day{
{Day: "1", Function: day1.Solve},
{Day: "2", Function: day2.Solve},
{Day: "3", Function: day3.Solve},
{Day: "4", Function: day4.Solve},
{Day: "5", Function: day5.Solve},
{Day: "6", Function: day6.Solve},
{Day: "7", Function: day7.Solve},
{Day: "8", Function: day8.Solve},
}
templates := &promptui.SelectTemplates{
Active: "\U000025CF {{ .Day | blue }}",
Inactive: "\U000025CB {{ .Day | red }}",
Selected: "{{ .Day | red | cyan }}",
}
searcher := func(input string, index int) bool {
day := days[index]
name := strings.Replace(strings.ToLower(day.Day), " ", "", -1)
input = strings.Replace(strings.ToLower(input), " ", "", -1)
return strings.Contains(name, input)
}
prompt := promptui.Select{
Label: "Which day would you like the solution to?",
Items: days,
Templates: templates,
Size: 8,
Searcher: searcher,
}
i, _, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
days[i].Function(fmt.Sprintf("day%s/input.txt", strconv.Itoa(i+1)))
}