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

View file

@ -0,0 +1,33 @@
package tree
import (
"fmt"
)
func DebugPrintTree(root *Node) {
debugPrintTreeR(root, 0)
}
func debugPrintTreeR(node *Node, level int) {
for i := 0; i < level; i++ {
fmt.Printf(" ")
}
DebugPrintNode(node)
for _, child := range node.Children {
debugPrintTreeR(child, level+1)
}
}
func DebugPrintNode(node *Node) {
fmt.Printf("%c @ %p. Children: ", node.Name, node)
for _, child := range node.Children {
fmt.Printf("%c ", child.Name)
}
fmt.Printf("Parents: ")
for _, parent := range node.Parents {
fmt.Printf("%c ", parent.Name)
}
fmt.Printf("\n")
}