diff --git a/day7/day7.cpp b/day7/day7.cpp index 4cb183a..1df60e2 100644 --- a/day7/day7.cpp +++ b/day7/day7.cpp @@ -175,7 +175,7 @@ int part2(const std::vector &input) { int recursivePart2(const BagMap &bagMap, const std::string &toVisit = DESIRED_BAG) { std::vector childBags = bagMap.at(toVisit); - return std::accumulate(childBags.cbegin(), childBags.cend(), 0, [&](int total, const ContainedBag &bag) { + return std::accumulate(childBags.cbegin(), childBags.cend(), 0, [&bagMap](int total, const ContainedBag &bag) { return total + bag.getQuantity() + bag.getQuantity() * recursivePart2(bagMap, bag.getColor()); }); }