aboutsummaryrefslogtreecommitdiff
path: root/src/2020/day4/aoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/2020/day4/aoc.cpp')
-rw-r--r--src/2020/day4/aoc.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/2020/day4/aoc.cpp b/src/2020/day4/aoc.cpp
index 171f42e..cd8fb64 100644
--- a/src/2020/day4/aoc.cpp
+++ b/src/2020/day4/aoc.cpp
@@ -2,26 +2,29 @@
namespace aoc2020 {
-int day4(line_view file) {
+std::pair<int, int> day4(line_view file) {
const char* p1 = file.line;
const char* p2 = file.line + file.length;
const char* p = p1;
- int total{0};
+ int t0{0};
+ int t1{0};
+ bool b1{false};
+ bool b2{false};
while (p < p2) {
if (*p == '\n' && *(p + 1) == '\n') {
- passwort pass{p1, p};
+ passport pass{p1, p};
// std::cout << pass << std::endl;
- if (pass.is_valid()) {
- total++;
- }
+ pass.is_valid(&b1, &b2);
+ t0 += int(b1);
+ t1 += int(b2);
p1 = p + 2;
}
p++;
}
- if (passwort{p1, p}.is_valid()) {
- total++;
- }
- return total;
+ passport{p1, p}.is_valid(&b1, &b2);
+ t0 += int(b1);
+ t1 += int(b2);
+ return {t0, t1};
}
} // namespace aoc2020