mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 15:10:49 +00:00
20 lines
483 B
Go
20 lines
483 B
Go
package main
|
|
|
|
// two returns the sum of all shortest distances between galaxies if space expand by a factor of 1000000
|
|
func two(lines []string) int {
|
|
compared := [][]int{}
|
|
sum := 0
|
|
for i := range galaxies {
|
|
for j := range galaxies {
|
|
if i == j || inCompared(i, j, compared) {
|
|
continue
|
|
}
|
|
|
|
compared = append(compared, []int{galaxies[i].identifier, galaxies[j].identifier})
|
|
sum += shortestRoute(galaxies[i].coords, galaxies[j].coords, 1000000)
|
|
}
|
|
}
|
|
|
|
return sum
|
|
}
|