diff --git a/2024/07.cpp b/2024/07.cpp index 83c1e74..c119423 100644 --- a/2024/07.cpp +++ b/2024/07.cpp @@ -12,7 +12,7 @@ namespace qi = boost::spirit::qi; namespace { -auto suffixed(std::uint64_t x, std::uint64_t y) -> std::optional +auto drop_suffix(std::uint64_t x, std::uint64_t y) -> std::optional { while (x > 0) { if (y == 0) { return x; } @@ -23,7 +23,7 @@ auto suffixed(std::uint64_t x, std::uint64_t y) -> std::optional return std::nullopt; } -auto check(bool const part2, std::uint64_t const target, std::vector const& numbers) -> bool +auto calibrated(bool const part2, std::uint64_t const target, std::vector const& numbers) -> bool { if (numbers.size() == 0) { return false; } @@ -41,7 +41,7 @@ auto check(bool const part2, std::uint64_t const target, std::vector void >>> (in, *(qi::ulong_long >> ':' >> *(' ' >> qi::ulong_long) >> '\n')); - std::uint64_t p1{}, p2{}; + std::uint64_t p1 = 0, p2 = 0; for (auto && [x, xs] : input) { - if (check(false, x, xs)) p1 += x; - if (check(true, x, xs)) p2 += x; + if (calibrated(false, x, xs)) p1 += x; + if (calibrated(true, x, xs)) p2 += x; } out << "Part 1: " << p1 << "\n"