Python2 - 37#
g=lambda x:(x%4or x%400and x%100<1)<1
Note that if a
is a nonnegative integer, then a<1
is a short way of writing not bool(a)
. The last <1
thus effectively converts the expression in the parentheses to a boolean and negates the result.
Applying the function g
to an integer n
between 1801 and 2400 will return True
if n
is a leap year, and False
otherwise.