aoc2023/day-11/two.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
}