adventofcode/2018/day08-1.go
2018-12-10 21:15:33 -05:00

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
}