Skip to main content
2 of 8
added 33 characters in body
bigyihsuan
  • 10.8k
  • 6
  • 8

Print the ends and middle of your code

The challenge is simple: Print the first, middle, and last character of your program's source code.

The middle character is defined as follows, assuming a source length of n characters, and 1-indexing:

  • If n is even, print the n/2-th and n/2 + 1-th character. (abcdef --> acdf)
  • If n is odd, print (n-1)/2 + 1-th character. (abcde --> ace)

Rules

  • Given no input, print the first, middle, and last character in your source code, in the form [first][middle][end].
  • Output must not contain any trailing whitespace. However, if whitespace is a first, middle, or last character, it must be printed as such.
  • Source code must be n >= 3 characters long.
  • This is , so shortest solution in characters wins.

Samples

print('p()') --> p()
abcd --> abcd
1 --> # not allowed
abcde --> ace
abcdef --> acdf
System.out.print("Spr;"); --> Spr;
this is a test --> ts t
123[newline]45 --> 13[newline]5

Tags:

bigyihsuan
  • 10.8k
  • 6
  • 8