blob: 6070d74cc512fadc2648662542cab48e6630495f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package main
import (
"fmt"
"os"
"git.adyxax.org/aoc/2021/18/pairs"
)
func main() {
max := 0
parser := pairs.NewParser(os.Stdin)
pairs := make([]*pairs.Pair, 0)
for {
pair, err := parser.Parse()
if err != nil {
break
}
pairs = append(pairs, pair)
}
l := len(pairs)
for i := 0; i < l; i++ {
for j := 0; j < l; j++ {
if i == j {
continue
}
p1 := pairs[i].DeepCopy()
p2 := pairs[j].DeepCopy()
if m := p1.Add(p2).Magnitude(); max < m {
max = m
}
}
}
fmt.Println(max)
}
|