aoc2023/day-11/two.go
2023-12-11 18:41:46 +00:00

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
}