30 lines
444 B
Go
30 lines
444 B
Go
|
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())
|
||
|
}
|