blob: d64262e71cde1915c606af69e64e8d6a6f9c016a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include "aoc.h"
#include <algorithm>
#include <vector>
namespace aoc2020 {
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});
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;
}
} // namespace aoc2020
|