-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
172 lines (167 loc) · 4.59 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package main
import (
"fmt"
"os"
"github.com/kprav33n/aoc23/day01"
"github.com/kprav33n/aoc23/day02"
"github.com/kprav33n/aoc23/day03"
"github.com/kprav33n/aoc23/day04"
"github.com/kprav33n/aoc23/day05"
"github.com/kprav33n/aoc23/day06"
"github.com/kprav33n/aoc23/day07"
"github.com/kprav33n/aoc23/day08"
"github.com/kprav33n/aoc23/day09"
"github.com/kprav33n/aoc23/day10"
"github.com/kprav33n/aoc23/day11"
"github.com/kprav33n/aoc23/day12"
"github.com/kprav33n/aoc23/day13"
"github.com/kprav33n/aoc23/day14"
"github.com/kprav33n/aoc23/day15"
"github.com/kprav33n/aoc23/day16"
"github.com/kprav33n/aoc23/io"
)
var solutions = map[string]func(){
"day01a": func() {
input := io.ReadLines("inputs/day01.txt")
fmt.Println(day01.SumOfCalibrationValues(input))
},
"day01b": func() {
input := io.ReadLines("inputs/day01.txt")
fmt.Println(day01.SumOfAdjustedCalibrationValues(input))
},
"day02a": func() {
input := io.ReadLines("inputs/day02.txt")
fmt.Println(day02.SumOfPossibleGameIDs(input,
day02.Combination{Red: 12, Green: 13, Blue: 14}))
},
"day02b": func() {
input := io.ReadLines("inputs/day02.txt")
fmt.Println(day02.SumOfPowers(input))
},
"day03a": func() {
input := io.ReadLines("inputs/day03.txt")
schematic := [][]rune{}
for _, line := range input {
schematic = append(schematic, []rune(line))
}
fmt.Println(day03.SumOfPartNumbers(schematic))
},
"day03b": func() {
input := io.ReadLines("inputs/day03.txt")
schematic := [][]rune{}
for _, line := range input {
schematic = append(schematic, []rune(line))
}
fmt.Println(day03.SumOfGearRatios(schematic))
},
"day04a": func() {
input := io.ReadLines("inputs/day04.txt")
fmt.Println(day04.TotalPoints(input))
},
"day04b": func() {
input := io.ReadLines("inputs/day04.txt")
fmt.Println(day04.TotalCards(input))
},
"day05a": func() {
input := io.ReadLines("inputs/day05.txt")
fmt.Println(day05.LowestLocation(input))
},
"day05b": func() {
input := io.ReadLines("inputs/day05.txt")
fmt.Println(day05.LowestLocationForRange(input))
},
"day06a": func() {
input := io.ReadLines("inputs/day06.txt")
fmt.Println(day06.ProductOfNumberOfWays(input))
},
"day06b": func() {
input := io.ReadLines("inputs/day06.txt")
fmt.Println(day06.NumberOfWays(input))
},
"day07a": func() {
input := io.ReadLines("inputs/day07.txt")
fmt.Println(day07.TotalWinnings(input))
},
"day07b": func() {
input := io.ReadLines("inputs/day07.txt")
fmt.Println(day07.TotalWinningsWithJoker(input))
},
"day08a": func() {
input := io.ReadLines("inputs/day08.txt")
fmt.Println(day08.NumStepsToDestination(input))
},
"day08b": func() {
input := io.ReadLines("inputs/day08.txt")
fmt.Println(day08.NumStepsToDestinationForGhost(input))
},
"day09a": func() {
input := io.ReadLines("inputs/day09.txt")
_, result := day09.SumOfExtrapolatedValues(input)
fmt.Println(result)
},
"day09b": func() {
input := io.ReadLines("inputs/day09.txt")
result, _ := day09.SumOfExtrapolatedValues(input)
fmt.Println(result)
},
"day10a": func() {
input := io.ReadLines("inputs/day10.txt")
fmt.Println(day10.StepsToFarthestPoint(input))
},
"day10b": func() {
input := io.ReadLines("inputs/day10.txt")
fmt.Println(day10.NumEnclosedTiles(input))
},
"day11a": func() {
input := io.ReadLines("inputs/day11.txt")
fmt.Println(day11.SumOfShortestPaths(input, 2))
},
"day11b": func() {
input := io.ReadLines("inputs/day11.txt")
fmt.Println(day11.SumOfShortestPaths(input, 1000000))
},
"day12a": func() {
input := io.ReadLines("inputs/day12.txt")
fmt.Println(day12.SumOfArrangements(input))
},
"day12b": func() {
input := io.ReadLines("inputs/day12.txt")
fmt.Println(day12.SumOfArrangementsX5(input))
},
"day13a": func() {
input := io.ReadLines("inputs/day13.txt")
fmt.Println(day13.SummaryNumber(input))
},
"day13b": func() {
input := io.ReadLines("inputs/day13.txt")
fmt.Println(day13.SummaryNumberWithSmudges(input))
},
"day14a": func() {
input := io.ReadLines("inputs/day14.txt")
fmt.Println(day14.TotalLoad(input))
},
"day15a": func() {
input := io.ReadLines("inputs/day15.txt")
fmt.Println(day15.SumOfStepHashes(input))
},
"day15b": func() {
input := io.ReadLines("inputs/day15.txt")
fmt.Println(day15.FocusingPower(input))
},
"day16a": func() {
input := io.ReadLines("inputs/day16.txt")
fmt.Println(day16.NumEnergizedTiles(input))
},
"day16b": func() {
input := io.ReadLines("inputs/day16.txt")
fmt.Println(day16.MaxEnergizedTiles(input))
},
}
func main() {
solution, ok := solutions[os.Args[1]]
if !ok {
fmt.Println("No solution found for", os.Args[1])
os.Exit(1)
}
solution()
}