First (unsuccessful) attempt at day 7.1.

This commit is contained in:
Anna Rose Wiggins 2018-12-09 23:46:35 -05:00
parent 0388b57112
commit f6ea56d266
No known key found for this signature in database
GPG key ID: 8D9ACA841015C59A
6 changed files with 238 additions and 0 deletions

29
2018/day07-1.go Normal file
View file

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