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 wrote:
For those who were curious why these could both work, note that
(A && B) || Cdiffers fromA && (B || C)in two cases: whenAis false,Cis true, andBis any value.But in this case in particular, those differences would create a bug when
Ais false (the year is not divisible by 4) at the same time thatCis true (the year is divisible by 400). Since that can't happen, the bug cannot occur.