adventofcode/2018/day08-1.go

25 lines
333 B
Go
Raw Normal View History

2018-12-11 01:23:18 +00:00
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 {
2018-12-11 02:15:33 +00:00
sum := node.SumMetadata()
2018-12-11 01:23:18 +00:00
for _, child := range node.Children {
sum += sumMetadata(child)
}
return sum
}