adventofcode/2018/day07-1.go

30 lines
447 B
Go
Raw Normal View History

package main
import (
"fmt"
"strings"
"internal/day07"
"internal/util"
)
func main() {
data := util.ReadInput()
// Build a tree of dependencies.
root := day07.BuildDependencyTree(data)
// Walk the tree and determine the correct ordering.
order := day07.FindOrder(root)
output := strings.Builder{}
for _, node := range order {
if node.Name == 0 {
continue
}
output.WriteRune(node.Name)
}
fmt.Println(output.String())
}