adventofcode/2018/day08-1.go

28 lines
365 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 := 0
for _, v := range node.Metadata {
sum += v
}
for _, child := range node.Children {
sum += sumMetadata(child)
}
return sum
}