-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (47 loc) · 1.17 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
package main
import (
"adventOfCode2024/processors"
"adventOfCode2024/readUtils"
"log"
"os"
"strconv"
"time"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Println("Cannot read .env file, make sure you have .env in the root of the project")
return
}
dayNo, err := strconv.Atoi(os.Getenv("DAY_NUMBER"))
if err != nil {
log.Println("DAY_NUMBER is not a valid integer")
return
}
if dayNo > 31 || dayNo < 1 {
log.Println("DAY_NUMBER can only be a number between 1 and 31")
return
}
log.Println("Env Variables loaded, proceeding ...")
input, err := readUtils.GetInput(dayNo)
if err != nil {
return
}
processFunc, err := processors.GetProcessor(dayNo)
if err != nil {
return
}
log.Printf("Starting processing input for Day %d ...\n", dayNo)
start := time.Now()
result1, result2, err := processFunc(input)
if err != nil {
log.Println("An error has occured while processing:", err)
return
}
elapsed := time.Since(start)
log.Print("Result part 1 : ", result1)
log.Print("Result part 2 : ", result2)
log.Printf("The algorithm used to solve the problem took %s\n", elapsed)
log.Println("Done.")
}