|
@@ -19,7 +19,7 @@ var directions = map[byte]common.Point{
|
19
|
19
|
// The number of steps is 0 if the point is the origin or if the wire doesn't
|
20
|
20
|
// reach that point.
|
21
|
21
|
func buildMap(origin common.Point, wires []string) map[common.Point][]int64 {
|
22
|
|
- points := map[common.Point][]int64{}
|
|
22
|
+ points := make(map[common.Point][]int64, 1000000)
|
23
|
23
|
|
24
|
24
|
for n, wire := range wires {
|
25
|
25
|
var (
|
|
@@ -64,7 +64,7 @@ func combinedSteps(steps []int64) (int64, bool) {
|
64
|
64
|
return res, true
|
65
|
65
|
}
|
66
|
66
|
|
67
|
|
-func main() {
|
|
67
|
+func traceWires() (int64, int64) {
|
68
|
68
|
wires := common.ReadFileAsStrings("03/input.txt")
|
69
|
69
|
origin := common.Point{X: 0, Y: 0}
|
70
|
70
|
points := buildMap(origin, wires)
|
|
@@ -86,6 +86,11 @@ func main() {
|
86
|
86
|
}
|
87
|
87
|
}
|
88
|
88
|
|
89
|
|
- fmt.Println(bestDistance)
|
90
|
|
- fmt.Println(bestSteps)
|
|
89
|
+ return bestDistance, bestSteps
|
|
90
|
+}
|
|
91
|
+
|
|
92
|
+func main() {
|
|
93
|
+ part1, part2 := traceWires()
|
|
94
|
+ fmt.Println(part1)
|
|
95
|
+ fmt.Println(part2)
|
91
|
96
|
}
|