# Is it a leap year?

This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not.

Your input will have no newlines or trailing spaces:

1954


You will output in any way that you like that clearly tells the user if it is or isn't a leap year (I will accept y or n for yes/no)

You can get a list of leap years here: http://kalender-365.de/leap-years.php I would note that leap years are not ever four years always. 1896 is a leap year, but 1900 is not. The years that follow this "skip" are:

1900
2100
2200
2300


Test cases:

1936 ->  y
1805 ->  n
1900 ->  n
2272 ->  y
2400 ->  y


EDIT: This is based on a standard Gregorian calendar: http://www.epochconverter.com/date-and-time/daynumbers-by-year.php

• You should be more clear: A given year is a leap year if and only if it is (divisible by 4)∧((divisible by 100)→(divisible by 400)). – LegionMammal978 May 26 '15 at 11:34
• Your input will have no newlines or trailing spaces. Dang it, that would have saved me 2 bytes... – Dennis May 26 '15 at 17:10
• You should extend the accepted input range to AD 1601 thru 2400. This covers two 400-year Gregorian cycles (which proleptically start on Monday). – David R Tribble May 26 '15 at 18:17
• Does falsy if leap year and truthy if not a leap year count as "clearly tells the user if it is or isn't"? – lirtosiast May 28 '15 at 21:27
• @lirtosiast I think so. A lot of user assume so. – aloisdg Jul 20 '16 at 13:58

# MathGolf, 9 bytes

4♀*]÷~≤*


Try it online!

## Explanation

4         Push 4
♀        Push 100
*      Duplicate top two elements of stack and multiply (400)
]     Wrap stack in array ([4, 100, 400])
÷    Check input for divisibility with all array items
~   Dump array onto stack
≤  Check if divisibility by 100 is <= than divisibility with 400
* Multiply with the divisibility bool for 4, works like logical and


The trick is that ≤ ensures that if a number is divisible by 100, it must also be divisible by 400, but if it's not divisible by 100, anything goes.

# Clam, 33 31 bytes

=a*rp|e%a*"400"0&%a*"100"e%a*40


Try it online!

-2 bytes thanks to ASCII-only

Outputs true for leap years. Outputs false for other years

## Explanation

=a*rp|e%a*"400"0&%a*"100"e%a*40
=a*r                             read input and store in a*
p                            Print..
%a*"400"                    a* % 400
e                            ==
0                   0
|                             OR
%a*"100"            a* % 100
&                    AND
%a*4       a* % 4
e           ==
0      0


Very awkward explanation, but basically what it does is this:

print(year % 400 == 0 || (year % 100 && year % 4 == 0))


Clam follows JS rules for truthy and falsey values, meaning year % 100 is true if it does not equal 0 (and it's shorter than adding an e before it and an 0 after it)

Resulting JS:

myVar = read();
console.log(year % 400 == 0 || (year % 100 && year % 4 == 0));


# JavaScript, 19 bytes

y=>!(y%25?y%4:y%16)


Try it online!

Swift, 82 bytes

func l(y:Int){y%4==0 && (y%100 != 0 || y%400==0) ?print("Y"):print("N")}
l(y:1936)


Try it online!

# PHP, 35 bytes

<?=date(L,strtotime(Jan.\$argv[1]));


Try it online!

Came across the L option in the PHP date formatter, which returns if the year of the date is a leap year. After that, it was just a matter of trying to get the timestamp of the year in the shortest way (though I'm not too confident this is the shortest)

# 05AB1E, 9 7 bytes

т‰0Kθ4Ö


Explanation:

т‰         # Divmod the (implicit) input by 100
#  i.e. 1900 → [19,00]
#  i.e. 1936 → [19,36]
#  i.e. 1991 → [19,91]
#  i.e. 2000 → [20,00]
0K       # Remove all 0s
#  i.e. [19,00] → [19]
#  i.e. [19,36] → [19,36]
#  i.e. [19,91] → [19,91]
#  i.e. [20,00] → [20]
θ      # Pop and get the last item
#  i.e. [19] → 19
#  i.e. [19,36] → 36
#  i.e. [19,91] → 91
#  i.e. [20] → 20
4Ö    # Check if it's divisible by 4 (and output the result implicitly)
#  i.e. 19 → 0 (falsey)
#  i.e. 36 → 1 (truthy)
#  i.e. 91 → 0 (falsey)
#  i.e. 20 → 1 (truthy)


# Reality, 1 byte

L


input via stdinput

The language was made after the challenge