First (unsuccessful) attempt at day 7.1.
This commit is contained in:
parent
0388b57112
commit
f6ea56d266
6 changed files with 238 additions and 0 deletions
29
2018/day07-1.go
Normal file
29
2018/day07-1.go
Normal 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())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue