Skip to main content
Roll back as suggested by Thomas Kwa
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 21 2727

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

Edit -6 chars, thanks David Hammen !(y%(y%25?4:16))

A function implementing the rule:

l=y=>!(y%(y%25?4:16)y%100<1&&y%400||y%4)

A test (run in Firefox) just to be sure:

l=y=>!(y%(y%25?4:16)y%100<1&&y%400||y%4)

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+(x?' <b>Y</b>':' <i>N</i>')+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}

b { color: red; }
i { color: blue; }
<table>
  <tr id=R></tr>
</table>

#JavaScript (ES6) 21 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

Edit -6 chars, thanks David Hammen !(y%(y%25?4:16))

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+(x?' <b>Y</b>':' <i>N</i>')+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}

b { color: red; }
i { color: blue; }
<table>
  <tr id=R></tr>
</table>

#JavaScript (ES6) 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+(x?' <b>Y</b>':' <i>N</i>')+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}

b { color: red; }
i { color: blue; }
<table>
  <tr id=R></tr>
</table>

added 126 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 2721 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

Edit -6 chars, thanks David Hammen !(y%(y%25?4:16))

A function implementing the rule:

l=y=>!(y%100<1&&y%400||y%4y%(y%25?4:16))

A test (run in Firefox) just to be sure:

l=y=>!(y%100<1&&y%400||y%4y%(y%25?4:16))

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+'+y+(x?' '+x+'\n'<b>Y</b>':' <i>N</i>')+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}

b { color: red; }
i { color: blue; }
<table>
  <tr id=R></tr>
</table>  

#JavaScript (ES6) 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+' '+x+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}
<table>
  <tr id=R></tr>
</table>  

#JavaScript (ES6) 21 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

Edit -6 chars, thanks David Hammen !(y%(y%25?4:16))

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+(x?' <b>Y</b>':' <i>N</i>')+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}

b { color: red; }
i { color: blue; }
<table>
  <tr id=R></tr>
</table>

added 1 character in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mailymainly using De Morgans's law)

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+' '+x+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}
<table>
  <tr id=R></tr>
</table>  

#JavaScript (ES6) 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (maily using De Morgans's law)

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+' '+x+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}
<table>
  <tr id=R></tr>
</table>  

#JavaScript (ES6) 27

The rule: (y%4==0) && (y%100!=0 || y%400==0)

Golfed: !(y%100<1&&y%400||y%4) (mainly using De Morgans's law)

A function implementing the rule:

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

A test (run in Firefox) just to be sure:

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

for(o=[],i=0;i<700;i++)
  y=i+1800,
  x=l(y),
  o[i/100|0]=(o[i/100|0]||'')+y+' '+x+'\n'
    
R.innerHTML='<td>'+o.join('</td><td>')+'</td>'
console.log(o[1])
td { white-space: pre; font-family: monospace; padding: 8px}
<table>
  <tr id=R></tr>
</table>  

Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading