Skip to main content
deleted 1 character in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

How it works

How it works

r   e# Read from STDIN.
S+  e# Append a space.
2m< e# Rotate two characters to the left.
~   e# Evaluate.
    e# So far, we achieved "1954" -> "54 19" -> 54 19.
e|  e# Logical OR; keep the leftmost non-zero integer.
4%! e# Logical NOT of the kept integer modulo 4.
    e# This pushes 1 for multiples of 4 and 0 otherwise.

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

How it works

r   e# Read from STDIN.
S+  e# Append a space.
2m< e# Rotate two characters to the left.
~   e# Evaluate.
    e# So far, we achieved "1954" -> "54 19" -> 54 19.
e|  e# Logical OR; keep the leftmost non-zero integer.
4%! e# Logical NOT of the kept integer modulo 4.
    e# This pushes 1 for multiples of 4 and 0 otherwise.

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

How it works

r   e# Read from STDIN.
S+  e# Append a space.
2m< e# Rotate two characters to the left.
~   e# Evaluate.
    e# So far, we achieved "1954" -> "54 19" -> 54 19.
e|  e# Logical OR; keep the leftmost non-zero integer.
4%! e# Logical NOT of the kept integer modulo 4.
    e# This pushes 1 for multiples of 4 and 0 otherwise.
added 284 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

How it works

r   e# Read from STDIN.
S+  e# Append a space.
2m< e# Rotate two characters to the left.
~   e# Evaluate.
    e# So far, we achieved "1954" -> "54 19" -> 54 19.
e|  e# Logical OR; keep the leftmost non-zero integer.
4%! e# Logical NOT of the kept integer modulo 4.
    e# This pushes 1 for multiples of 4 and 0 otherwise.

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

How it works

r   e# Read from STDIN.
S+  e# Append a space.
2m< e# Rotate two characters to the left.
~   e# Evaluate.
    e# So far, we achieved "1954" -> "54 19" -> 54 19.
e|  e# Logical OR; keep the leftmost non-zero integer.
4%! e# Logical NOT of the kept integer modulo 4.
    e# This pushes 1 for multiples of 4 and 0 otherwise.
added 284 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

CJam, 12 bytes

rS+2m<~e|4%!

CJam, 12 bytes

rS+2m<~e|4%!

This full program read from STDIN and prints 1 for leap years and 0 otherwise.

Verify the test cases yourself in the CJam interpreter.

Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading