Skip to main content
Saved 2 bytes by changing negation
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 3030 28 bytes

y->!(y%4<1)&y%100<1|!(y%400<1y%4<1&&y%100>0)||y%400<1

This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. f=y->....

Ungolfed:

function f(y)
    !(y % 4 == 0) &&& y % 100 ==!= 0) ||| !(y % 400 == 0)
end

ExamplesExample:

julia> for y in [1936, 1805, 1900, 2272, 2400] println(f(1936y)) end
true
 
julia> f(1805)false
false
true
true
true

Julia, 30 bytes

y->!(y%4<1)&y%100<1|!(y%400<1)

This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. f=y->....

Ungolfed:

function f(y)
    !(y % 4 == 0) & y % 100 == 0 | !(y % 400 == 0)
end

Examples:

julia> f(1936)
true
 
julia> f(1805)
false

Julia, 30 28 bytes

y->(y%4<1&&y%100>0)||y%400<1

This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. f=y->....

Ungolfed:

function f(y)
    (y % 4 == 0 && y % 100 != 0) || y % 400 == 0
end

Example:

julia> for y in [1936, 1805, 1900, 2272, 2400] println(f(y)) end
true
false
false
true
true
true
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 30 bytes

y->!(y%4<1)&y%100<1|!(y%400<1)

This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. f=y->....

Ungolfed:

function f(y)
    !(y % 4 == 0) & y % 100 == 0 | !(y % 400 == 0)
end

Examples:

julia> f(1936)
true

julia> f(1805)
false