diff options
Diffstat (limited to 'src/2020/day6/aoc.h')
-rw-r--r-- | src/2020/day6/aoc.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/2020/day6/aoc.h b/src/2020/day6/aoc.h index c5ad3d1..dc2989d 100644 --- a/src/2020/day6/aoc.h +++ b/src/2020/day6/aoc.h @@ -3,4 +3,29 @@ namespace aoc2020 { -} +struct question_group { + line_view people; + int count[26] = {0}; + + int summary() const noexcept { + int total{0}; + for (int x : count) { + total += int(x > 0); + } + return total; + } + + question_group(line_view lv) : people(lv) { + const char* p = lv.line; + while (p < lv.line + lv.length) { + if (*p >= 'a' && *p <= 'z') { + count[*p - 'a'] += 1; + } + p++; + } + } +}; + +int day6(line_view); + +} // namespace aoc2020 |