# 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

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

# Language Name, N bytes


where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes


If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes


You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes


var QUESTION_ID=188005;
var OVERRIDE_USER=78850;
var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(d){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(d,e){return"https://api.stackexchange.com/2.2/answers/"+e.join(";")+"/comments?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){answers.push.apply(answers,d.items),answers_hash=[],answer_ids=[],d.items.forEach(function(e){e.comments=[];var f=+e.share_link.match(/\d+/);answer_ids.push(f),answers_hash[f]=e}),d.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){d.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),d.has_more?getComments():more_answers?getAnswers():process()}})}getAnswers();var SCORE_REG=function(){var d=String.rawh\d,e=String.raw\-?\d+\.?\d*,f=String.raw[^\n<>]*,g=String.raw<s>${f}</s>|<strike>${f}</strike>|<del>${f}</del>,h=String.raw[^\n\d<>]*,j=String.raw<[^\n<>]+>;return new RegExp(String.raw<${d}>+String.raw\s*([^\n,]*[^\s,]),.*?+String.raw(${e})+String.raw(?=+String.raw${h}+String.raw(?:(?:${g}|${j})${h})*+String.raw</${d}>+String.raw))}(),OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(d){return d.owner.display_name}function process(){var d=[];answers.forEach(function(n){var o=n.body;n.comments.forEach(function(q){OVERRIDE_REG.test(q.body)&&(o="<h1>"+q.body.replace(OVERRIDE_REG,"")+"</h1>")});var p=o.match(SCORE_REG);p&&d.push({user:getAuthorName(n),size:+p[2],language:p[1],link:n.share_link})}),d.sort(function(n,o){var p=n.size,q=o.size;return p-q});var e={},f=1,g=null,h=1;d.forEach(function(n){n.size!=g&&(h=f),g=n.size,++f;var o=jQuery("#answer-template").html();o=o.replace("{{PLACE}}",h+".").replace("{{NAME}}",n.user).replace("{{LANGUAGE}}",n.language).replace("{{SIZE}}",n.size).replace("{{LINK}}",n.link),o=jQuery(o),jQuery("#answers").append(o);var p=n.language;p=jQuery("<i>"+n.language+"</i>").text().toLowerCase(),e[p]=e[p]||{lang:n.language,user:n.user,size:n.size,link:n.link,uniq:p}});var j=[];for(var k in e)e.hasOwnProperty(k)&&j.push(e[k]);j.sort(function(n,o){return n.uniq>o.uniq?1:n.uniq<o.uniq?-1:0});for(var l=0;l<j.length;++l){var m=jQuery("#language-template").html(),k=j[l];m=m.replace("{{LANGUAGE}}",k.lang).replace("{{NAME}}",k.user).replace("{{SIZE}}",k.size).replace("{{LINK}}",k.link),m=jQuery(m),jQuery("#languages").append(m)}}
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654"> <div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> 

• 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 '19 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 '19 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 '19 at 19:35
• @Belhenix Whitespace is certainly possible, it has enough unique valid characters (space, linefeed, tab). – bigyihsuan Jul 9 '19 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-Moving 2 Codidact Jul 10 '19 at 14:10

# SNOBOL4 (CSNOBOL4), 19 bytes


OUTPUT = 'D='
END


Try it online!

Prints D=<newline>, using SNOBOL's trailing newline in OUTPUT.

D=

# Lenguage, 292 2340 bytes

Thanks to Jimmy23013 for pointing out I need another 2048 bytes

2340 bytes of any character with the first, middle two and last characters being a null byte.

Prints 4 null characters.

Try it online in brainfuck

• @jimmy23013 ok should be fixed now – Expired Data Jul 9 '19 at 15:44

main=putStr"\"Sm"


Try it online!

• Identical with Damien's Haskell solution posted almost 2 hour 50 minutes earlier. – manatwork Jul 10 '19 at 17:22

# Retina 0.8.2, 7 bytes


01$*$$ Try it online! Retina 0.8.2 outputs a trailing newline by default, so the code starts with that. Conveniently, this also matches the default empty input, allowing the replace stage to get to work. It then suffices to come up with a string of even length > 2 that outputs the other 2 characters. # Retina, 7 bytes ((K((  Try it online! Retina 1 does not output a trailing newline by default, but fortunately it has the K command which allows us to specify a constant string output. The grouping construct ( is used to increase the number of distinct characters to meet the minimum requirement. # Dodos, 22 bytes  dot dot 0 0  Try it online! # Runic Enchantments, 9 7 bytes '@'':r@  Try it online! -2 bytes by just using char literals. Outputs @'' # 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 '19 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 '19 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 '19 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 '19 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 '19 at 17:15
• it seems to me that the output should be '''LF for this source code – mazzy Jul 10 '19 at 5:56
• @mazzy One day I'll post an answer that's up to spec. – Veskah Jul 10 '19 at 12:04
• nice. 7 bytes, 3 unique chars :) – mazzy Jul 10 '19 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 '19 at 12:29
• @Abigail That still breaks the same rule about trailing whitespace. – Chris Jul 30 '19 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 '19 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 '19 at 15:26
• Now is correct, but became exact copy of Grzegorz Oledzki's Bash solution posted yesterday. – manatwork Jul 11 '19 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 '19 at 16:08
• Oh yeah, fixed it – EdgyNerd Jul 12 '19 at 16:45
• Oh, didn’t realise that. Does it auto fill the last byte of output to 8 bits? – EdgyNerd Jul 13 '19 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.