diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/2022/day16/aoc.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/2022/day16/aoc.cpp b/src/2022/day16/aoc.cpp index 658357c..460b29a 100644 --- a/src/2022/day16/aoc.cpp +++ b/src/2022/day16/aoc.cpp @@ -77,7 +77,7 @@ void flow(int m, valve* v, std::set<valve*> opened, int total, int* max) { // choose next for (auto& n : diagram[v]) { - if (m >= n.m) { + if (m >= n.m && opened.find(n.v) == opened.end()) { flow(m - n.m, n.v, opened, total, max); } } @@ -110,18 +110,9 @@ std::pair<int, int> day16(line_view file) { diagram.insert({v, vs}); } - // for (auto& kv : diagram) { - // valve* v = kv.first; - // std::cout << v->name << ": "; - // for (auto& n : kv.second) { - // std::cout << n.v->name << "(" << n.m << ") "; - // } - // std::cout << std::endl; - // } - int max{INT32_MIN}; std::set<valve*> opened; - flow(30, get("AA"), opened, 0, &max); + flow(29, get("BB"), opened, 0, &max); printf("%d\n", max); |