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

100 Answers 100

176
\$\begingroup\$

JavaScript, 9 7 bytes

N=>a=-N

Outputs: NaN

Try it online!

\$\endgroup\$
  • 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 Jul 10 '19 at 6:33
  • 50
    \$\begingroup\$ This is one of the best Javascript answers I've ever seen here \$\endgroup\$ – Daniel Jul 10 '19 at 7:42
21
\$\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\$
  • 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\$ – Kevin Cruijssen Jul 9 '19 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\$ – Robin Ryder Jul 9 '19 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\$ – Kevin Cruijssen Jul 9 '19 at 17:03
  • 1
    \$\begingroup\$ 17 bytes: wWWwww  wWWwWWWww \$\endgroup\$ – jimmy23013 Jul 10 '19 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\$ – Robin Ryder Jul 10 '19 at 8:29
17
\$\begingroup\$

brainfuck, 17 bytes

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

Try it online!

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

\$\endgroup\$
  • 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 Jul 9 '19 at 15:20
  • 17
    \$\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 Jul 9 '19 at 15:25
  • 1
    \$\begingroup\$ Shouldn't it be U-[>+<-UU--]>...U? In its current form the code only shows one U \$\endgroup\$ – Helena Jul 9 '19 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 Jul 11 '19 at 14:05
  • 3
    \$\begingroup\$ Why don't you simply use ÿ-.ÿ..ÿ? That's printable and short. \$\endgroup\$ – Dorian Jul 25 '19 at 8:09
17
\$\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\$
  • 2
    \$\begingroup\$ I wasn't expecting Shakespeare to show up for this. This is great \$\endgroup\$ – bigyihsuan Jul 10 '19 at 2:34
  • 1
    \$\begingroup\$ Wish I could +1 just for learning this language existed! \$\endgroup\$ – Stilez Jul 10 '19 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 Jul 12 '19 at 12:52
  • 1
    \$\begingroup\$ 163 bytes for the second version by ending with a ! \$\endgroup\$ – Robin Ryder Jul 17 '19 at 10:34
  • 1
    \$\begingroup\$ @UnrelatedString OK, thanks! Done. \$\endgroup\$ – Robin Ryder Jul 17 '19 at 17:36
14
\$\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\$
  • 6
    \$\begingroup\$ Both output trailing whitespace (newline), which is not allowed. Python 2 alternative: Try it online! \$\endgroup\$ – wastl Jul 9 '19 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\$ – Geza Kerecsenyi Jul 9 '19 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 Jul 9 '19 at 16:48
  • 1
    \$\begingroup\$ @GezaKerecsenyi Just a guideline \$\endgroup\$ – mbomb007 Jul 9 '19 at 19:01
  • \$\begingroup\$ @wastl Thanks! Fixed. \$\endgroup\$ – TFeld Jul 9 '19 at 19:15
11
\$\begingroup\$

RProgN 2, 3 bytes

1
0

Try it online!

I think this is valid?

\$\endgroup\$
  • \$\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 Jul 9 '19 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 Jul 9 '19 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\$ – Kevin Cruijssen Jul 9 '19 at 15:48
  • \$\begingroup\$ I believe this is polyglot in tac on Linux. \$\endgroup\$ – tsh Jul 10 '19 at 6:38
11
\$\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\$
8
\$\begingroup\$

PHP, 9 bytes

<?=";;<";

Try it online!

\$\endgroup\$
  • 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\$ – manassehkatz-Moving 2 Codidact Jul 10 '19 at 14:13
7
\$\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\$
  • \$\begingroup\$ Isn't 121 also a valid trivial answer? \$\endgroup\$ – Teleporting Goat Jul 10 '19 at 9:51
  • \$\begingroup\$ @TeleportingGoat: No, because it has only two distinct characters \$\endgroup\$ – Oliver Hankeln Jul 10 '19 at 13:28
7
\$\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\$
  • 1
    \$\begingroup\$ Parentheses! (Lightbulb) I got stuck with the last character needing to be ". Well done! \$\endgroup\$ – Wernisch Jul 11 '19 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\$ – william porter Jul 12 '19 at 15:08
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\$
  • 3
    \$\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 Jul 9 '19 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 Jul 9 '19 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\$
  • \$\begingroup\$ it's smart answer \$\endgroup\$ – mazzy Jul 10 '19 at 6:48
  • 1
    \$\begingroup\$ allowed because 0x0a != 0x0d != 0x31 :) \$\endgroup\$ – bigyihsuan Jul 10 '19 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\$
  • 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\$ – Kevin Cruijssen Jul 11 '19 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 Jul 11 '19 at 11:21
6
\$\begingroup\$

DOS/Windows Batch Language, 9 bytes

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

Ruby, 11 9 bytes

print:ptp

Try it online!

\$\endgroup\$
5
\$\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\$
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\$

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\$
  • \$\begingroup\$ Welcome to Code Golf SE! You can save a couple bytes by skipping the copy, like so. \$\endgroup\$ – Khuldraeseth na'Barya Jul 10 '19 at 21:47
5
\$\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\$
4
\$\begingroup\$

CJam, 7 bytes

'@'' _@

Try it online!

\$\endgroup\$
  • 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\$ – Erik the Outgolfer Jul 9 '19 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 Jul 9 '19 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\$ – Erik the Outgolfer Jul 9 '19 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\$

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\$

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\$
  • \$\begingroup\$ Seeing Chef programs makes me wonder what is the bare minimum for it. \$\endgroup\$ – bigyihsuan Jul 11 '19 at 13:35
  • \$\begingroup\$ @bigyihsuan see my edit \$\endgroup\$ – user24343 Jul 12 '19 at 15:45
  • \$\begingroup\$ You can remove all the "the"'s and make the program still work. \$\endgroup\$ – user85052 Jul 13 '19 at 4:15
  • \$\begingroup\$ I created a working program. (177 bytes) \$\endgroup\$ – user85052 Jul 13 '19 at 4:27
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\$
  • 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 Jul 10 '19 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 Jul 10 '19 at 12:50
  • \$\begingroup\$ This prints a trailing newline but doesn't account for it. \$\endgroup\$ – user85052 Jul 15 '19 at 13:40
  • \$\begingroup\$ Not sure if newlines count as whitespaces but I added the 2nd also 13-byte version. \$\endgroup\$ – jaaq Jul 16 '19 at 9:53
  • 1
    \$\begingroup\$ Yes, newlines count as whitespace, just like tabs and spaces among others \$\endgroup\$ – Jo King Jul 16 '19 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\$
4
\$\begingroup\$

C (gcc), 21 bytes


main(){puts("}u");;}

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Print the last, middle, and first character of your program's source code, in that order. You're printing first, middle, last! \$\endgroup\$ – wastl Jul 9 '19 at 13:53
  • 1
    \$\begingroup\$ oops, I just realized that. \$\endgroup\$ – Johan du Toit Jul 9 '19 at 13:54
  • 1
    \$\begingroup\$ If there is an even number of characters, you need two middle characters. (sorry ...) \$\endgroup\$ – wastl Jul 9 '19 at 14:03
3
\$\begingroup\$

Haskell, 17 bytes

main=putStr"\"Sm"

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Java 8, 11 bytes (as lambda function)

v->'"'+"'v"

Outputs "'v.

Try it online.

Java 8, 67 bytes (as full program)

interface M{static void main(String[]ar){System.out.print("}ni");}}

Outputs }ni.

Note the ar instead of a as argument. Otherwise the middle part had to be in, but printing that would make the size odd again, which would cause a paradox-loop..

Try it online.

\$\endgroup\$
  • 2
    \$\begingroup\$ @racraman Please don't go edit other peoples answers. If you have a golf to suggest, leave a comment stating so. Also, your golf on my answer was incorrect. Your code would output vv", but it's supposed to output it in reverse, so it should have output "vv. \$\endgroup\$ – Kevin Cruijssen Jul 11 '19 at 10:18
3
\$\begingroup\$

MathGolf, 5 4 bytes

1231

-1 byte by using the trivial solution presented by @ErikTheOutgolfer in his Jelly answer, which works for any language with implicit output without trailing newline.

Try it online.

Original 5 bytes answer:

ùù xx

Outputs x ù.

Try it online.

Explanation:

ùù x   # Push 3-char string "ù x"
    x  # Reverse it to "x ù"
       # (output the entire string joined together implicitly without trailing newline)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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