aboutsummaryrefslogtreecommitdiff
path: root/2021/18/first.go
blob: ffe70504b6687ec1a09bb387c672a73ac632d766 (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
package main

import (
	"fmt"
	"log"
	"os"

	"git.adyxax.org/aoc/2021/18/pairs"
)

func main() {
	parser := pairs.NewParser(os.Stdin)
	pair, err := parser.Parse()
	if err != nil {
		log.Fatalf("%w", err)
	}
	for {
		pair2, err := parser.Parse()
		if err != nil {
			break
		}
		pair = pair.Add(pair2)
	}
	fmt.Println(pair)
	pair.Reduce()
	fmt.Println(pair)
	fmt.Println(pair.Magnitude())
}