aoc/2023/08/part2/cmd/main.go

44 lines
753 B
Go
Raw Permalink Normal View History

2023-12-09 15:39:30 +00:00
package main
import (
"bufio"
"os"
"fmt"
"git.tristans.cloud/tristan/aoc/2023/08/part2/part2"
"git.tristans.cloud/tristan/aoc/2023/08/part1/part1"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin);
ins, err := reader.ReadString('\n');
if err != nil {
fmt.Println("Halted too soon!")
return
}
ins = strings.Trim(ins, "\n")
_, err = reader.ReadString('\n');
if err != nil {
fmt.Println("Halted too soon!")
return
}
net := part1.Network{}
for {
line, err := reader.ReadString('\n');
if err != nil {
break
}
err = part1.AddToNet(net, line)
if err != nil {
fmt.Println(err, line, net)
}
}
steps, err := part2.StepsToSolveAll(ins, net)
if (err != nil) {
fmt.Println(err)
}
fmt.Println(steps)
}