feat: implement PartTwo using DFS recursion

This commit is contained in:
2025-11-28 12:53:29 +01:00
parent 33bcb91d48
commit 60ffe95f69

View File

@@ -90,5 +90,16 @@ func PartOne(data []string) int {
}
func PartTwo(data []string) int {
return 0
forwardGraph := buildForwardGraph(data)
var countIndividualBags func(string) int
countIndividualBags = func(bag string) int {
total := 0
for _, child := range forwardGraph[bag] {
total += child.count + child.count*countIndividualBags(child.bag)
}
return total
}
return countIndividualBags("shiny gold")
}