For those who were curious why these could both work, note that
(A && B) || C differs from A &&
(B || C) in two cases: when A is
false, C is true, and B is any value.
But in this case in particular, those differences would create a bug
when A is false (the year is not divisible by 4) at the
same time that C is true (the year is
divisible by 400). Since that can't happen, the bug cannot occur.
Thaumasiotes said:
For those who were curious why these could both work, note that
(A && B) || C
differs fromA && (B || C)
in two cases: whenA
is false,C
is true, andB
is any value.But in this case in particular, those differences would create a bug when
A
is false (the year is not divisible by 4) at the same time thatC
is true (the year is divisible by 400). Since that can't happen, the bug cannot occur.