# Print the last, middle and first character of your code

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

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 == cd)
• If n is odd, print (n-1)/2 + 1-th character. (abcde == c)

### Rules

• Given no input, print the last, middle, and first character in your source code, in the form [last][middle][first]. This will be 3-4 characters long.
• 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.
• Code must consist of >= 3 unique characters.
• Standard loopholes are forbidden.
• This is , so shortest solution in characters wins.

### Samples

# Form: [code] --> [output]
xyz --> zyx
abcd --> dbca
1 --> # not allowed: too short
abcde --> eca
aaabb --> # not allowed: not enough unique characters
System.out.print("S;pr"); --> ;prS
this is a test --> ts t
123[newline]45 --> 53[newline]1


Challenge Proposal

• Maybe it's only me, but "Code must consist of >= 3 unique characters." suggests all characters of the program should be unique, while you only require to have at least 3 distinct characters. – Grzegorz Oledzki Jul 9 at 19:22
• @Belhenix Fewer than three unique characters allows solutions as simple as 121 for a great many languages. – Khuldraeseth na'Barya Jul 9 at 19:32
• If anyone can find a stack-based language that uses - for negation and implicitly prints with a linefeed, \n1- is a three-byter. My search has so far been fruitless. – Khuldraeseth na'Barya Jul 9 at 19:35
• @Belhenix Whitespace is certainly possible, it has enough unique valid characters (space, linefeed, tab). – bigyihsuan Jul 9 at 19:46
• Can't change it now with 58 answers, but requiring "first letter of code must be different from last letter of code" would have ruled out a lot of trivial answers, including the current top answer. That may have been the intent of ">= 3 unique characters", but that requirement isn't actually very hard. – manassehkatz-Reinstate Monica Jul 10 at 14:10

# Gaia, 5 bytes


⌋ ”⌋


Try it online!

The ⌋ is just there as a no-op.

            % helper function
⌋ ”⌋         % main function: push "⌋ " and convert to lowercase
% then implicitly print with trailing newline


# Gema, 13 characters

\A=l\\\\@fail


Try it online!

# Brachylog, 7 bytes

"w\\""w


Try it online!

Thanks to Shaggy for correcting this to comply with the challenge specification.

Boring string literal, except thanks to the weird way Brachylog string literals work, the escaped backslash also still escapes the quote afterwards, so it's not actually that boring.

• Ah, you're right, I didn't read the spec closely enough. Thanks! – Unrelated String Jul 9 at 20:11
• Coincidentally, I'd just added your original version as an alternative to my Japt solution - scrolled down and thought I'd found a polyglot! – Shaggy Jul 9 at 20:37

# Japt, 7 bytes

''ixi''


Try it

''ixi''
''          :Literal "'"
i         :Prepend
x        :  Literal "x" (any lowercase letter would work. Except i, of course)
i       :  Prepend
''     :    Literal "'"


## Alternatives

"\"ww"w


Try it


Riii'R

Try it

"Q\""+Q


Try it

# HTML, 4 bytes

^db^

^<X>_<X>^

I'm not sure if this is cheating... Really.

First one also worked as PHP or Text.

• It's my bad that not creating a page for txeT before this challenge... – tsh Jul 10 at 3:01

# Lua, 31 13 bytes

print (')(p')


Prints )(p

Try it online!

# dc, 9 characters

[PP]P91aP


Sample run:

bash-5.0$dc -e '[PP]P91aP' PP[  Try it online! # MarioLANG, 53 bytes +>(-[!) +"===#+ ++ ++ ++ ++ ++ + )!) <... =#==="==+  Try it online! Output: +++. The 27th character is one of the + characters in the second column of the code. # cQuents, 8 bytes 1#11,2&1  Try it online! Outputs 11,1. # Explanation 1 Prepend 1 to the output #11,2 Default input is 11, 2 & Output as many terms as the last input, comma seperated 1 Each term equals 1  So first 1 is prepended, then the input becomes 11,2. Then, we output 2 terms comma separated, which is 1,1, so the final output is 11,1. # PowerShell, 8 7 bytes  ' D'  Try it online! Notice the two spaces after the last quote. Forgot that using implicit output puts a newline afterwards. Fixing that saved a byte though. ## Alternative 7 byte solution with 3 unique chars by mazzy  """"  Try it online! • Actually, 1231 doesn't work since PowerShell outputs a trailing newline by default. 1231 only works in languages with implicit output without trailing newline. – Kevin Cruijssen Jul 9 at 17:06 • @KevinCruijssen Yeah, didn't even think about that even though my current answer takes it into account. Purge inbound. – Veskah Jul 9 at 17:15 • it seems to me that the output should be '''LF for this source code – mazzy Jul 10 at 5:56 • @mazzy One day I'll post an answer that's up to spec. – Veskah Jul 10 at 12:04 • nice. 7 bytes, 3 unique chars :) – mazzy Jul 10 at 14:48 # Wolfram Language (Mathematica), 9 bytes  Print@nn  Try it online! # PHP, 11 bytes <?=';\\<';;  Try it online! # Perl 5, 11 bytes say "\"\\s"  Try it online! • This violates the rule "Output must not contain any trailing whitespace. However, if whitespace is a first, middle, or last character, it must be printed as such." – Chris Jul 11 at 12:29 • @Abigail That still breaks the same rule about trailing whitespace. – Chris Jul 30 at 10:24 # BitCycle, 5 bytes  11!1  Try it online! Outputs 11 with a trailing newline. Only the first pair of 1s is actually printed. # LOLCODE, 27 bytes HAI 1 VISIBLE "E H" KTHXBYE  Try it online! Trivial answer in LOLCODE. The 14th character is the space just before the string literal. # Perl 5, 11 bytes  say '; ';  Try it online! Note the initial newline and the trailing space. Outputs ;  # Bash, 911 9 bytes ## First attempt: echo e\ o  Output e o  ## Second attempt: echo -n e-e  Output: e-e  ## Third attempt  echo oo  Note the leading newline and the double space Output: oo  • Welcome to codegolf.se. It should print in the order of the last, middle and first character, o e for your current code. – jimmy23013 Jul 10 at 15:19 • Also “Output must not contain any trailing whitespace.” I'm afraid your contains, actually outputs 4 characters instead of 3. – manatwork Jul 10 at 15:26 • Now is correct, but became exact copy of Grzegorz Oledzki's Bash solution posted yesterday. – manatwork Jul 11 at 13:06 # SmileBASIC, 7 bytes ?":b?":  Output: :b? (Probably works in most BASIC dialects) The middle character can be anything except ", LF, and CR. # F#, 13 bytes (characters) So many esoteric languages that seem to be made specifically for code golfing… let's try a terse but 'normal' language like F#, where the following line (without a trailing newline) has 13 characters (13 bytes if the source file is saved as ANSI text): printf"\"\"p"  Output: ""p  # Pyth, 5 bytes  10 1  Prints 10 followed by a newline. Try it online! Newlines normally print the next result followed by a newline, but at the start of a program it is essentially a no-op. 10 is the literal value, which is printed followed by a newline. The space before the 1 suppresses the usual implicit printing, so the final 1 is ignored. # Zsh, 9 bytes  <<<\<\<  Try it online! Hexdump, with first/middle/last bytes highlighted: 00000000: 0a0a 3c3c 3c5c 3c5c 3c ..<<<\<\< F^ M^ L^ ^ ^ ^  Output is <<[newline]. # Boolfuck, 29 21 bytes ;;;;;;;;;;;;;;;;;+  Outputs 3 null characters Thanks to Jo King for the improved solution! Try it online! ## BitChanger, 23 bytes <<<<<<<<<<}<<<}<}<}<  Very similar to the Boolfuck one: uses the fact the null characters require no bit changing to output with tape-based bit output ## How it works:  Used as it is simple to output <<<<<<<<<< Moves over to one left of the I/O bit } Sets the I/O bit to one, for output <<< Moves over to the bit that performs I/O }<}<} Sets it to one 3 times, to output 3 null characters < I used < to waste one byte so it could be an odd number of bytes  Try it Online! • Sure it matched the requirement “Code must consist of >= 3 unique characters.”? – manatwork Jul 12 at 16:08 • Oh yeah, fixed it – EdgyNerd Jul 12 at 16:45 • Oh, didn’t realise that. Does it auto fill the last byte of output to 8 bits? – EdgyNerd Jul 13 at 7:55 # Octave, 15 bytes fprintf(')(f' )  Try it online! As far as I know, using fprintf is the only method of out that doesn't come with extraneous output. # Python 2, 12 bytes 11 bytes Placeholder to make the leading newline visible print"\"t"  • This is 12 bytes and hence is even, so you must print the 6th and 7th character of your code, which is ' ' and '"' so you should print " "p not " p like you currently do. Also please consider adding a link to e.g. Try It Online. – Expired Data Jul 15 at 10:19 • It also prints an extra newline, which is not allowed. – jimmy23013 Jul 15 at 11:50 • This 11 byte solution may be valid. Do you agree? @jimmy23013 – Expired Data Jul 15 at 14:27 • @ExpiredData Yes it works. – jimmy23013 Jul 15 at 14:51 # Rust (closure), 9 bytes || ";;|";  Try it online! # Rust (full program), 25 bytes fn main(){print!("}}if")}  Try it online! # Pip, 15 bytes O"}"xxL1{O"1O"}  Needs more golfing Try it online! # Pip, 9 bytes  O"nn"x n  shorter version with newline Try it online! # Pip, 8 bytes 1x000Oh1  another one Try it online! # Ohm v2, 5 bytes …Lo…L  Try it online! # Haskell, 19 bytes  main=($LT)print--L


Try it online! Outputs LT<newline>.

# ink, 5 bytes


/a//


Prints /a and a newline

Try it online!

# DOS COM x86 binary

% xxd test.com
00000000: 31c9 4b88 2f80 ffef 75f8 8007 30b4 028a  1.K./...u...0...
00000010: 17cd 2180 3f00 7503 e905 00fe 0fe9 f3ff  ..!.?.u.........
00000020: b402 8a17 cd21 8007 20b4 028a 17cd 2190  .....!.. .....!.
00000030: cd20 4b53 20                             . KS