diff options
Diffstat (limited to 'src/2020/day6/aoc.cpp')
-rw-r--r-- | src/2020/day6/aoc.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/2020/day6/aoc.cpp b/src/2020/day6/aoc.cpp index d64262e..5f44585 100644 --- a/src/2020/day6/aoc.cpp +++ b/src/2020/day6/aoc.cpp @@ -4,23 +4,27 @@ namespace aoc2020 { -int day6(line_view file) { +std::pair<int, int> day6(line_view file) { std::vector<question_group> gs; const char* p1 = file.line; const char* p = p1; while (p < file.line + file.length) { if (*p == '\n' && *(p + 1) == '\n') { - gs.emplace_back(line_view{p1, p}); + gs.emplace_back(line_view{p1, p + 1}); p1 = p + 2; } p++; } gs.emplace_back(line_view{p1, p}); - int total{0}; - std::for_each(gs.begin(), gs.end(), [&total](const question_group& g) { total += g.summary(); }); - return total; + int t0{0}; + int t1{0}; + std::for_each(gs.begin(), gs.end(), [&t0, &t1](const question_group& g) { + t0 += g.summary(); + t1 += g.common(); + }); + return {t0, t1}; } } // namespace aoc2020 |