25 lines
333 B
Go
25 lines
333 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"internal/day08"
|
|
"internal/util"
|
|
)
|
|
|
|
func main() {
|
|
data := util.ReadInputInts()
|
|
root := day08.BuildTree(data)
|
|
fmt.Println(sumMetadata(root))
|
|
}
|
|
|
|
func sumMetadata(node *day08.Node) int {
|
|
sum := node.SumMetadata()
|
|
|
|
for _, child := range node.Children {
|
|
sum += sumMetadata(child)
|
|
}
|
|
|
|
return sum
|
|
}
|