diff --git a/src/day1/p1/faf.cpp b/src/day1/p1/faf.cpp index 7bae14a..c3d5f35 100644 --- a/src/day1/p1/faf.cpp +++ b/src/day1/p1/faf.cpp @@ -89,14 +89,13 @@ int main() { auto [next, ec] = std::from_chars(ptr, end, number); ptr = next; - while (ptr < end && (*ptr == '\n' || *ptr == '\r')) { - ++ptr; - } + if (ptr < end && *ptr == '\r') ++ptr; + if (ptr < end && *ptr == '\n') ++ptr; if (is_right) { state = (state + number) % 100; } else { - state = (state - number % 100 + 100) % 100; + state = (state + 100 - number % 100) % 100; } password += (state == 0);