diff options
Diffstat (limited to 'src/2020/day4/aoc.cpp')
-rw-r--r-- | src/2020/day4/aoc.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/2020/day4/aoc.cpp b/src/2020/day4/aoc.cpp index 849bad9..171f42e 100644 --- a/src/2020/day4/aoc.cpp +++ b/src/2020/day4/aoc.cpp @@ -2,4 +2,26 @@ namespace aoc2020 { +int day4(line_view file) { + const char* p1 = file.line; + const char* p2 = file.line + file.length; + const char* p = p1; + int total{0}; + while (p < p2) { + if (*p == '\n' && *(p + 1) == '\n') { + passwort pass{p1, p}; + // std::cout << pass << std::endl; + if (pass.is_valid()) { + total++; + } + p1 = p + 2; + } + p++; + } + if (passwort{p1, p}.is_valid()) { + total++; + } + return total; } + +} // namespace aoc2020 |