-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (51 loc) · 976 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"aoc2024go/day13"
"aoc2024go/utils"
"fmt"
"time"
)
func main() {
day := day13.Day13{}
isPart1 := true
isTest := false
result := runSolution(day, isTest, isPart1)
var partLabel, testLabel string
if isPart1 {
partLabel = "part 1"
} else {
partLabel = "part 2"
}
if isTest {
testLabel = "test input"
} else {
testLabel = "real input"
}
fmt.Printf(
"The result for day%d, %s, %s is %d \n",
day.Id(),
partLabel,
testLabel,
result,
)
}
func runSolution(day utils.Day, isTest bool, isPart1 bool) int {
var result int
start := time.Now()
lines := day.LoadFile(isTest)
startFun := time.Now()
var err error
if isPart1 {
result, err = day.Part1(lines)
} else {
result, err = day.Part2(lines)
}
if err != nil {
panic(err)
}
timeFun := time.Since(startFun)
timeTotal := time.Since(start)
fmt.Println("Total exec time is ", timeTotal)
fmt.Println("Function exec time is", timeFun)
return result
}