diff options
-rw-r--r-- | src/2022/day16/aoc.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/2022/day16/aoc.cpp b/src/2022/day16/aoc.cpp index 5ef909f..fad148c 100644 --- a/src/2022/day16/aoc.cpp +++ b/src/2022/day16/aoc.cpp @@ -100,6 +100,20 @@ void flow(int m, valve* v, std::map<valve*, int> opened, int os, int total, int* } } +void flow(int m, valve* v1, valve* v2, std::map<valve*, int> opened, int os, int total, int* max) { + update_total(&total, opened, m); + if (m == 0) { + if (*max < total) { + *max = total; + } + } else { + if (os >= maxopened) { + flow(m - 1, v1, v2, opened, os, total, max); + } else { + } + } +} + std::pair<int, int> day16(line_view file) { per_line(file, [](line_view lv) { valve* v = new valve{lv}; @@ -139,6 +153,10 @@ std::pair<int, int> day16(line_view file) { std::map<valve*, int> opened; flow(30, get("AA"), opened, 0, 0, &m1); + opened.clear(); + int m2{INT32_MIN}; + flow(26, get("AA"), get("AA"), opened, 0, 0, &m2); + return {m1, 0}; } |