77
\$\begingroup\$

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

Leaderboards

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

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# 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.raw`h\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> 

\$\endgroup\$
12
  • 6
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 9, 2019 at 19:22
  • 4
    \$\begingroup\$ @Belhenix Fewer than three unique characters allows solutions as simple as 121 for a great many languages. \$\endgroup\$ Commented Jul 9, 2019 at 19:32
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 9, 2019 at 19:35
  • 3
    \$\begingroup\$ @Belhenix Whitespace is certainly possible, it has enough unique valid characters (space, linefeed, tab). \$\endgroup\$
    – bigyihsuan
    Commented Jul 9, 2019 at 19:46
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 10, 2019 at 14:10

144 Answers 144

1
2 3 4 5
203
\$\begingroup\$

JavaScript, 9 7 bytes

N=>a=-N

Outputs: NaN

Try it online!

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Very clever. This was the tact I was trying to take, but just couldn't stumble upon a language with curt enough error output. \$\endgroup\$
    – ouflak
    Commented Jul 10, 2019 at 6:33
  • 55
    \$\begingroup\$ This is one of the best Javascript answers I've ever seen here \$\endgroup\$
    – Daniel
    Commented Jul 10, 2019 at 7:42
  • 1
    \$\begingroup\$ I saw javascript and got shocked. Then I read the actual solution and laughed much harder than I should have. Congratulations!! \$\endgroup\$
    – Stefano
    Commented Jan 21, 2022 at 11:03
23
\$\begingroup\$

Grass, 17 bytes

wWWwwwVVwWWwWWWww

Try it online!

-2 bytes thanks to jimmy23013.

Outputs www. Grass ignores all characters apart from w, W and v. The two Vs are thus ignored; they are there to ensure the middle character is a w – I have no idea how to output v or W in Grass… I could have used another character instead of V, but V preserves the aesthetic of the code.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ "Luckily, the middle character ended up being a w and not a v or a W – I have no idea how to output v or W in Grass…" Lol. xD I tried to do something similar in Whitespace having also only three characters (space, tab, newline), but unfortunately I wasn't so lucky.. Luckily I can simply add a bunch of trailing no-ops to fix it, though. \$\endgroup\$ Commented Jul 9, 2019 at 14:56
  • \$\begingroup\$ @KevinCruijssen If the middle character had been anything else, I would probably have added in the middle a bunch of xs (or any other non-Grass character, which Grass ignores) to move a w into the correct place. \$\endgroup\$ Commented Jul 9, 2019 at 16:51
  • \$\begingroup\$ Ah, I'm an idiot.. I can insert a non-whitespace character as well which Whitespace will ignore. ;) -2 bytes thanks to you. \$\endgroup\$ Commented Jul 9, 2019 at 17:03
  • 1
    \$\begingroup\$ 17 bytes: wWWwww  wWWwWWWww \$\endgroup\$
    – jimmy23013
    Commented Jul 10, 2019 at 7:05
  • \$\begingroup\$ @jimmy23013 Thanks! And thanks for posting your tip; I needed it to understand what you did! I changed the spaces to Vs because I find it prettier. ;-) \$\endgroup\$ Commented Jul 10, 2019 at 8:29
21
\$\begingroup\$

brainfuck, 17 bytes

U-[>+<-UU--]>...U

Try it online!

With unprintables this can be reduced to 7 bytes: ␀..␀_.␀

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Within the rules, but BF doesn't use U as an instruction. Functionally,the code is -[>+<---]>., so the expected output would be .--, which it does not output. \$\endgroup\$
    – bigyihsuan
    Commented Jul 9, 2019 at 15:20
  • 18
    \$\begingroup\$ @bigyihsuan but the source code still contains the Us and this interpreter happily ignores them. Should every answer which has comments or multiple spaces (or anything else that doesn't necessarily matter to the language) be not counted? \$\endgroup\$
    – dzaima
    Commented Jul 9, 2019 at 15:25
  • 1
    \$\begingroup\$ Shouldn't it be U-[>+<-UU--]>...U? In its current form the code only shows one U \$\endgroup\$
    – Helena
    Commented Jul 9, 2019 at 17:32
  • 1
    \$\begingroup\$ @Flater Yes, here they're used to make the challenge easier, but isn't that the whole purpose of the code-golf tag? Many answers here alone make their job easier by adding leading/trailing whitespace, and in general in code-golf here anything following the rules is allowed (and if I had to guess, if there was a rule disallowing unused characters (defining which objectively would already be pretty much impossible) would mean that the challenge might be still hovering at 0 score, and probably be closed as well). \$\endgroup\$
    – dzaima
    Commented Jul 11, 2019 at 14:05
  • 5
    \$\begingroup\$ Why don't you simply use ÿ-.ÿ..ÿ? That's printable and short. \$\endgroup\$
    – Dorian
    Commented Jul 25, 2019 at 8:09
18
\$\begingroup\$

Shakespeare Programming Language, 119 bytes

 ,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]
Ajax:  You big big big big big cat.Speak thy.Speak thy.Speak thy. 

Try it online!

Prints three spaces. Without printing spaces:

Shakespeare Programming Language, 227 bytes

,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]Ajax:You is the sum of a big big big big big big cat a big pig.
You is the sum of you a large huge large big pig.
Speak thy.Speak thy.You is the sum of you a big pig.Speak thy.

Try it online!

Like my newline-free INTERCAL answer, this is constructed to make the last character of the program the same as the middle character (although in this case it is not also the first), by un-golfing the second half of the code until they match. (I'm not sure if I could have constructed 46 in fewer bytes or not, or if I could have golfed other parts of the first half more.)

\$\endgroup\$
7
  • 2
    \$\begingroup\$ I wasn't expecting Shakespeare to show up for this. This is great \$\endgroup\$
    – bigyihsuan
    Commented Jul 10, 2019 at 2:34
  • 1
    \$\begingroup\$ Wish I could +1 just for learning this language existed! \$\endgroup\$
    – Stilez
    Commented Jul 10, 2019 at 22:15
  • 1
    \$\begingroup\$ even in the online interpreter's debug output messages, the authors' sense of humor shows: Warning at line 2: 'mind' expected \$\endgroup\$
    – dlatikay
    Commented Jul 12, 2019 at 12:52
  • 1
    \$\begingroup\$ 163 bytes for the second version by ending with a ! \$\endgroup\$ Commented Jul 17, 2019 at 10:34
  • 1
    \$\begingroup\$ @UnrelatedString OK, thanks! Done. \$\endgroup\$ Commented Jul 17, 2019 at 17:36
15
\$\begingroup\$

Python 2, 13 11 bytes


print' t' 

To make the whitespace clear:

$ xxd solution.py
0000000: 0a70 7269 6e74 2720 7427 20           .print' t'
$ python2 solution.py | xxd
0000000: 2074 0a                                t.

Try it online!

-2 bytes, thanks to wastl !

\$\endgroup\$
5
  • 6
    \$\begingroup\$ Both output trailing whitespace (newline), which is not allowed. Python 2 alternative: Try it online! \$\endgroup\$
    – wastl
    Commented Jul 9, 2019 at 13:59
  • \$\begingroup\$ Also, I don't think this is valid: Python requires you to have an empty newline at the end of your code. \$\endgroup\$ Commented Jul 9, 2019 at 15:59
  • 5
    \$\begingroup\$ @GezaKerecsenyi As I understand it, a newline at the end of the source code is just a recommendation. See PEP8. \$\endgroup\$
    – mypetlion
    Commented Jul 9, 2019 at 16:48
  • 1
    \$\begingroup\$ @GezaKerecsenyi Just a guideline \$\endgroup\$
    – mbomb007
    Commented Jul 9, 2019 at 19:01
  • \$\begingroup\$ @wastl Thanks! Fixed. \$\endgroup\$
    – TFeld
    Commented Jul 9, 2019 at 19:15
13
\$\begingroup\$

05AB1E, 7 5 bytes


„ RR

Outputs R \n.

-2 bytes by taking inspiration from @Neil's Batch answer, so make sure to upvote him as well!

Try it online.

5 bytes alternative by @Grimy:


12,1

Outputs 12\n.

Try it online.

Initial 7 bytes answer:

'?„«'«?

Outputs ?«'.

Try it online.

Explanation:

          # No-op newline
„ R       # Push 2-char string " R"
   R      # Reverse this string to "R "
          # (output the result implicitly with trailing newline)

          # No-op newline
12,       # Print 12 with trailing newline
   1      # Push a 1 (no implicit printing, since we already did an explicit print)

'?       '# Push 1-char string "?"
  „«'    '# Push 2-char string "«'"
     «    # Concatenate them both together
      ?   # Output without trailing newline
\$\endgroup\$
1
10
\$\begingroup\$

RProgN 2, 3 bytes

1
0

Try it online!

I think this is valid?

\$\endgroup\$
4
  • \$\begingroup\$ I'm guessing 1 and 0 are pushed onto a stack, then an implicit pop-print at the end of the program? Yes it's valid \$\endgroup\$
    – bigyihsuan
    Commented Jul 9, 2019 at 15:21
  • 3
    \$\begingroup\$ @bigyihsuan that's what I'm guessing too; I don't know the language, I just recall it does stuff like this :p \$\endgroup\$
    – dzaima
    Commented Jul 9, 2019 at 15:22
  • \$\begingroup\$ @dzaima Haha, when you post an answer and you don't even know how it works. xD I've indeed seen RProgN a few times before with old [quine] challenges, before the quine-rules got changed. \$\endgroup\$ Commented Jul 9, 2019 at 15:48
  • \$\begingroup\$ I believe this is polyglot in tac on Linux. \$\endgroup\$
    – tsh
    Commented Jul 10, 2019 at 6:38
9
\$\begingroup\$

Jelly, 5 bytes

001 0

Try it online!

The output has two distinct characters, but the code also has a third one.

Trivial 4-byte version:

1231
\$\endgroup\$
2
  • \$\begingroup\$ Isn't 121 also a valid trivial answer? \$\endgroup\$ Commented Jul 10, 2019 at 9:51
  • \$\begingroup\$ @TeleportingGoat: No, because it has only two distinct characters \$\endgroup\$ Commented Jul 10, 2019 at 13:28
8
\$\begingroup\$

PHP, 9 bytes

<?=";;<";

Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Actually, since PHP outputs code as text until the first <? tag, you could use one of the trivial 4-byte solutions like 1231 - anything without a special character as first and last, any other 2 characters in the middle. Your answer may be the shortest real code PHP answer. \$\endgroup\$ Commented Jul 10, 2019 at 14:13
8
\$\begingroup\$

Excel, 9 bytes

=("))=" )

So many Parentheses.

Note: The returned middle character can actually be any character since it's the middle of the code.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Parentheses! (Lightbulb) I got stuck with the last character needing to be ". Well done! \$\endgroup\$
    – Wernisch
    Commented Jul 11, 2019 at 8:34
  • \$\begingroup\$ Thanks! It was something I was trying to figure out as well, and then I remembered that parentheses would work. \$\endgroup\$
    – willuwontu
    Commented Jul 12, 2019 at 15:08
7
\$\begingroup\$

DOS/Windows Batch Language, 9 bytes

@echo @o@
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf & Coding Challenges Stack Exchange, +1 for nice first post! \$\endgroup\$
    – user85052
    Commented Jul 12, 2019 at 11:41
6
\$\begingroup\$

Batch, 9 characters


@echo hh

The middle and last character are both h, and then the echo prints a newline by default, which is the first character of the script.

\$\endgroup\$
6
\$\begingroup\$

Ruby, 6 bytes


p " "

Try it online!

This outputs " " plus a newline. The code ends with a ", the middle two characters are and ", and it starts with a newline.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ I like your badge, I believe it's a grayscale xor on N². I generated almost the same picture to help me for a Project Euler Nim problem. Does your badge have a story? \$\endgroup\$
    – Damien
    Commented Jul 9, 2019 at 14:54
  • 1
    \$\begingroup\$ Nice catch! I just like "doodling" during meetings by generating pictures using one-liners; xor was an early favorite. \$\endgroup\$
    – histocrat
    Commented Jul 9, 2019 at 15:23
6
\$\begingroup\$

PowerShell, 3 bytes

00000000: 0a0d 31                                  ..1

Works only in Microsoft Windows.

The output is unfortunately 8 bytes in UTF-16. But the question says output the characters, and not the bytes. Arguably UTF-16 is just one of the supported ways to represent the characters in PowerShell. They are not interpreted differently from an ASCII file.

\$\endgroup\$
2
  • \$\begingroup\$ it's smart answer \$\endgroup\$
    – mazzy
    Commented Jul 10, 2019 at 6:48
  • 1
    \$\begingroup\$ allowed because 0x0a != 0x0d != 0x31 :) \$\endgroup\$
    – bigyihsuan
    Commented Jul 10, 2019 at 12:55
6
\$\begingroup\$

Bash (15 11 characters)

echo -n e-e

which prints out

e-e
  • -4 chars by not using |rev
\$\endgroup\$
2
  • 1
    \$\begingroup\$ @racraman Your suggested edit of echo<space>e<space><space>e will output e<space>e<newline> instead of e<space>e, so I've rejected it. The newline is part of the output, which is why GrzegorzOledzki is using the -n option. Try echo -n e-e online vs Try echo e e online. And again, please don't edit other peoples answer. If you have a golf to suggest, leave a comment. \$\endgroup\$ Commented Jul 11, 2019 at 10:22
  • \$\begingroup\$ also 11 bytes with printf pfp, but only because we need two spaces due to that definition of middle character, otherwise it would be 10 ... \$\endgroup\$
    – pLumo
    Commented Jul 11, 2019 at 11:21
6
\$\begingroup\$

Underload, 9 bytes 7 bytes

Thanks to Khuldraeseth na'Barya for the improved solution!

W(SSW)S

As for as I can tell, this is now unimprovable since:

  • The first character has to be a no-op character, since every other instruction raises an error due to the stack being empty, with the exception being an opening bracket. However, it can't be that since there is no way to output an opening bracket on it's own in Underload.
  • You need to use at least 5 characters to add the 3 output characters to the stack.
  • You need to use S to output it.

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf SE! You can save a couple bytes by skipping the copy, like so. \$\endgroup\$ Commented Jul 10, 2019 at 21:47
6
\$\begingroup\$

Shakespeare Programming Language, 163 153 bytes

-10 bytes thanks to Jo King.

B,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]Ajax:You is
the sum ofa Big Big Big BIG BIG cat a
CAT.Speak thy.You is twice you.Speak thy!SPEAK THY!

Try it online!

My first SPL answer! Outputs !BB.

There is another SPL answer by Unrelated String; in that answer, they output only spaces in 119 bytes, or output non-space characters in 227 bytes. This one comes in between, and also outputs non-space characters.

Two tricks are used here:

  1. An SPL sentence can end with ! rather than ., and ! is easier to get since its ASCII codepoint is 33 (=\$2^5+1\$), whereas the codepoint of . is 46.
  2. Doubling 33 gives 66, the codepoint of B, hence the play title is B and I need the second "big" to be "Big", which works since SPL is case-insensitive.

Since I needed that capital B and an exclamation mark at the end, I decided to have Ajax shout louder and louder through the scene.

\$\endgroup\$
0
6
\$\begingroup\$

It feels cheaty, but

Mornington Crescent, 1005 bytes

Take Northern Line to Euston









Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Victoria
Take Victoria Line to Tottenham Hale
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Gunnersbury
Take District Line to Acton Town
Take District Line to Acton Town
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Leicester Square
Take Northern Line to Leicester Square
Take Northern Line to Mornington Crescent

There are nine deliberately placed newlines after the first instruction to make the middle character the o of Take District Line to Upminster. The code prints out the first three characters of Tottenham Hale reversed to yield toT. Of course, this challenge was made easier by the fact that Mornington Crescent programs always start with the T of Take and end with the t of Mornington Crescent, barring any extra newlines.

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I've just realized that this works in TIO (Esoterpret) but not in Esoteric IDE. \$\endgroup\$
    – Cloudy7
    Commented Jun 14, 2020 at 0:55
5
\$\begingroup\$

Ruby, 11 9 bytes

print:ptp

Try it online!

\$\endgroup\$
5
\$\begingroup\$

ArnoldC, 61 bytes

IT'S SHOWTIME
TALK TO THE HAND "D I"
YOU HAVE BEEN TERMINATED

Try it online!

Trivial answer in ArnoldC. The 31st byte is the space just before the string literal.

\$\endgroup\$
5
\$\begingroup\$

Chef, 447 bytes

Last Middle First Milkshake.

This recipe prints its last, middle and first character.
You could also use it to make a milkshake. 

Ingredients.
76 ml milk
32 ml chocolate syrup
46 teaspoons vanilla ice cream

Method.
Liquefy vanilla ice cream.
Put the milk into 1st mixing bowl.
Put the chocolate syrup into 1st mixing bowl.
Put the vanilla ice cream into 1st mixing bowl.
Pour contents of the 1st mixing bowl into the 1st baking dish.

Serves 1.

Try it online!

A serious submission, 196 177 bytes

thanks to A__

R.

Ingredients.
82 l a
103 l b
46 l c

Method.
Put a into mixing bowl.
Put b into mixing bowl.
Put c into mixing bowl.
Pour contents of mixing bowl into baking dish.

Serves 1.

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Seeing Chef programs makes me wonder what is the bare minimum for it. \$\endgroup\$
    – bigyihsuan
    Commented Jul 11, 2019 at 13:35
  • \$\begingroup\$ @bigyihsuan see my edit \$\endgroup\$
    – user24343
    Commented Jul 12, 2019 at 15:45
  • \$\begingroup\$ You can remove all the "the"'s and make the program still work. \$\endgroup\$
    – user85052
    Commented Jul 13, 2019 at 4:15
  • \$\begingroup\$ I created a working program. (177 bytes) \$\endgroup\$
    – user85052
    Commented Jul 13, 2019 at 4:27
5
\$\begingroup\$

TI-Basic, 3 bytes

i+1

i represents the imaginary number.

\$\endgroup\$
5
+100
\$\begingroup\$

Knight, 7 bytes


O"OO"O

Try it online!

Prints OO<newline>.

Whitespace is ignored, O is monadic output function which prints the string "OO" without quotes and a trailing newline, and the last O is ignored because the parsing ends at O"OO".

Knight, 7 bytes


O-1 2-

Try it online!

Prints -1<newline>.

\$\endgroup\$
1
  • \$\begingroup\$ Absolutely brilliant, I love it. \$\endgroup\$
    – Sampersand
    Commented Aug 14, 2022 at 23:23
4
\$\begingroup\$

CJam, 7 bytes

'@'' _@

Try it online!

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Pretty sure 0 1 0 is shorter and also has three distinct characters (I don't want to repost my Jelly approach :P). \$\endgroup\$ Commented Jul 9, 2019 at 14:19
  • 1
    \$\begingroup\$ @EriktheOutgolfer Well though!. But that's just like your answerm so I'll leave this as is \$\endgroup\$
    – Luis Mendo
    Commented Jul 9, 2019 at 14:20
  • 2
    \$\begingroup\$ Yeah, that's why I commented, didn't really want to post the same thing twice. (Hm... this might be the optimal solution for many languages.) Anyway, yours might be applicable elsewhere too! \$\endgroup\$ Commented Jul 9, 2019 at 14:24
4
\$\begingroup\$

Befunge-93, 7 bytes

.",  @0

Try it online!

Explanation

Output is 0 .

.       pop value (0) from stack, output as number with a trailing space
 "      toggle string mode, wraps around and pushes every char to the stack
  ,     pop value (".") from stack, output as character 
        spaces are no-ops
     @  end the program
      0 trailing 0 to match the output
\$\endgroup\$
4
\$\begingroup\$

Brain-Flak, 11 bytes

(((())))

Try it online!

Explanation

We need to put 3 things on the stack. The fastest way to do that is to put 3 1s (or zeros) on the stack. Now since  (code point 1) does nothing in Brain-Flak we can add these to the program at the first middle and last places. Now this feels a bit cheaty so here are two more answers that are less cheaty in my opinion.

Prints braces, 31 bytes

( (((((()()()()()){}){}){}))())

Try it online!

This answer prints braces so that the characters printed are actually relevant to the code, it does have one padding character to make the length odd so we only have to print 1 middle character.

Contains only braces, 32 bytes

(((()((((()(()()){}){}){}){}))))

Try it online!

This is a braces only program both the source and (consequently) the output are made up entirely of braces (character Brain-Flak actually cares about).

\$\endgroup\$
4
\$\begingroup\$

APL (Dyalog Unicode), 5 4 bytes

Full programs.

Boring solution from J.Sallé:

1231

Prints that number. A much more interesting solution:

010E1

Try it online!

APL ignores leading zeros, so this is simply scaled format for 10×10¹=100.

\$\endgroup\$
4
\$\begingroup\$

Python 3, 19 bytes 13 bytes


print( ')(')

The print function appends a newline by default so the code starts with a newline. The last character of the code is a ")" so that's printed first. To make the number of characters uneven, a space in inserted before the argument of the print function. Please excuse the salaciousness of the code.

Outputs: )(\n

Try it online.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Depending on how the rules work I might have 13 bytes playing with your answer: ` print(")(" )` Note there is a new line above print and a whitespace inside print after ")(". Outputs: )( with a new line at the end. \$\endgroup\$
    – Hoog
    Commented Jul 10, 2019 at 12:38
  • \$\begingroup\$ Thanks, down to 13 bytes! As the question specifically refers to whitespaces but not newlines I'll assume trailing newlines, as the default end parameter of the print function, don't count. \$\endgroup\$
    – jaaq
    Commented Jul 10, 2019 at 12:50
  • \$\begingroup\$ This prints a trailing newline but doesn't account for it. \$\endgroup\$
    – user85052
    Commented Jul 15, 2019 at 13:40
  • \$\begingroup\$ Not sure if newlines count as whitespaces but I added the 2nd also 13-byte version. \$\endgroup\$
    – jaaq
    Commented Jul 16, 2019 at 9:53
  • 1
    \$\begingroup\$ Yes, newlines count as whitespace, just like tabs and spaces among others \$\endgroup\$
    – Jo King
    Commented Jul 16, 2019 at 11:47
4
\$\begingroup\$

33, 9 bytes

a"a\\a"pa

The a's do nothing here, they're essentially NOPs in this code to make it shorter. My original thought was "p\\\""p, but that's 8 bytes, so it needs to print another \, making it 10 bytes "p\\\\\""p

This is a language I did create, but I made it legitimately, so I hope it's within the rules.

\$\endgroup\$
4
\$\begingroup\$

Whitespace, 31 29 bytes

[S aS S T   S S S S S N
_Push_32][S N
S _Duplicate_32][S N
S _Duplicate_32][T  N
S S _Print_as_character][T  N
S S _Print_as_character][T  N
S S _Print_as_character]

-2 bytes thanks to @RobinRyder.

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs, and new-lines only).

Contains a no-op a (can be any non-whitespace character) to make the length odd. It is added before the first halve of the program so the middle character is a space as well, since the middle character would have become a newline if it was at the second halve of the program. All non-whitespace characters are ignored in Whitespace programs.

\$\endgroup\$
1
2 3 4 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.