mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 15:10:49 +00:00
21 lines
499 B
Go
21 lines
499 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
|
||
|
}
|
||
|
|
||
|
dist := shortestRoute(galaxies[i].coords, galaxies[j].coords, 1000000)
|
||
|
compared = append(compared, []int{galaxies[i].identifier, galaxies[j].identifier})
|
||
|
sum += dist
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return sum
|
||
|
}
|