Print the last, middle and first character of your code

61

1

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> 

bigyihsuan

Posted 2019-07-09T13:33:35.997

Reputation: 1 483

6Maybe 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 – 2019-07-09T19:22:11.693

1I also think codes should be allowed to have few unique characters. I'd love to see a whitespace answer, it might even have a newline in the output – Belhenix – 2019-07-09T19:29:39.347

4@Belhenix Fewer than three unique characters allows solutions as simple as 121 for a great many languages. – Khuldraeseth na'Barya – 2019-07-09T19:32:51.993

2If 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 – 2019-07-09T19:35:11.737

@GrzegorzOledzki That bit means you can't cheese the challenge by having an answer like aba, which is 2 unique characters. However, abc or aabc would be allowed. – bigyihsuan – 2019-07-09T19:45:13.583

3@Belhenix Whitespace is certainly possible, it has enough unique valid characters (space, linefeed, tab). – bigyihsuan – 2019-07-09T19:46:43.743

@bigyihsuan got it. I sympathize with the rule. I just make a minor remark that the wording of the rule is not fully precise. – Grzegorz Oledzki – 2019-07-09T19:49:26.023

1Just type 1231 into a python interpreter... – Apollys supports Monica – 2019-07-10T00:18:35.853

@bigyihsuan, aabc definitely doesn't contain >= 3 unique characters. It contains two unique characters and one duplicated one. – Peter Taylor – 2019-07-10T10:14:17.977

2Can'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 – 2019-07-10T14:10:39.663

Your second from the last sample output looks wrong. "this is a test --> s tt" – James – 2019-07-11T15:26:06.593

@James Seems to be the case. Need to change that... – bigyihsuan – 2019-07-11T15:54:08.910

Answers

176

JavaScript, 9 7 bytes

N=>a=-N

Outputs: NaN

Try it online!

Oliver

Posted 2019-07-09T13:33:35.997

Reputation: 7 160

4Very clever. This was the tact I was trying to take, but just couldn't stumble upon a language with curt enough error output. – ouflak – 2019-07-10T06:33:47.033

50This is one of the best Javascript answers I've ever seen here – Daniel – 2019-07-10T07:42:01.350

21

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.

Robin Ryder

Posted 2019-07-09T13:33:35.997

Reputation: 6 625

1

"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.

– Kevin Cruijssen – 2019-07-09T14:56:03.557

@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. – Robin Ryder – 2019-07-09T16:51:41.337

Ah, I'm an idiot.. I can insert a non-whitespace character as well which Whitespace will ignore. ;) -2 bytes thanks to you. – Kevin Cruijssen – 2019-07-09T17:03:04.183

117 bytes: wWWwww  wWWwWWWww – jimmy23013 – 2019-07-10T07:05:53.400

@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. ;-)

– Robin Ryder – 2019-07-10T08:29:06.393

17

brainfuck, 17 bytes

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

Try it online!

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

ovs

Posted 2019-07-09T13:33:35.997

Reputation: 21 408

1Within 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. – bigyihsuan – 2019-07-09T15:20:44.943

17@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? – dzaima – 2019-07-09T15:25:54.353

1Shouldn't it be U-[>+<-UU--]>...U? In its current form the code only shows one U – Helena – 2019-07-09T17:32:01.043

@Helena thanks for catching that. – ovs – 2019-07-09T17:36:10.760

@dzaima: There is an ongoing argument that golfing entails minimizing code to the smallest viable product, thus inherently disallowing comments or ignored characters. I'm on the fence about it. While I usually err on the side of allowing comments in general, it feels less okay to do so for quines as the challenge is in the code. This answer effectively avoids the "middle character of the code" requirement by artificially shifting the middle character. – Flater – 2019-07-11T09:05:21.477

@Flater "disallowing comments or ignored characters" doesn't follow from "minimizing code to the smallest viable product". Very often it may be the case, but here (and in many other answers in many other challenges) it is most definitely not. Noone's advocating disallowing comments in general (or I would hope so), only when they obviously don't help golfiness. – dzaima – 2019-07-11T13:26:38.343

@dzaima: It's a matter of conforming to the rules of the challenge. The reason they're generally allowed is because they generally are only to the detriment of an entry (byte count wise - the predominant challenge measure). In other challenges they may even be desirable (e.g. involving ASCII art). However, here they're being used to pretty much circumvent a key requirement of the challenge (it must be the middle character which is also printed). This is different from the usual challenges and here it avoids part of the challenge. – Flater – 2019-07-11T13:56:55.580

1@Flater Yes, here they're used to make the challenge easier, but isn't that the whole purpose of the [tag: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). – dzaima – 2019-07-11T14:05:01.863

3Why don't you simply use ÿ-.ÿ..ÿ? That's printable and short. – Dorian – 2019-07-25T08:09:04.910

17

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.)

Unrelated String

Posted 2019-07-09T13:33:35.997

Reputation: 5 300

2I wasn't expecting Shakespeare to show up for this. This is great – bigyihsuan – 2019-07-10T02:34:24.710

1Wish I could +1 just for learning this language existed! – Stilez – 2019-07-10T22:15:04.430

@Stilez It's actually not that uncommon on here. There's a whole [tag:tips] page on it (which I copy-pasted the program header from) – Unrelated String – 2019-07-10T22:16:45.767

1even in the online interpreter's debug output messages, the authors' sense of humor shows: Warning at line 2: 'mind' expected – dlatikay – 2019-07-12T12:52:34.670

1163 bytes for the second version by ending with a ! – Robin Ryder – 2019-07-17T10:34:32.640

@RobinRyder I think that's substantially different enough in how it shows actual understanding of the language that it deserves to be its own answer. Go forth and reap the reputation, you've earned it – Unrelated String – 2019-07-17T10:57:19.277

1

@UnrelatedString OK, thanks! Done.

– Robin Ryder – 2019-07-17T17:36:32.403

14

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 !

TFeld

Posted 2019-07-09T13:33:35.997

Reputation: 19 246

6

Both output trailing whitespace (newline), which is not allowed. Python 2 alternative: Try it online!

– wastl – 2019-07-09T13:59:27.313

Also, I don't think this is valid: Python requires you to have an empty newline at the end of your code. – Geza Kerecsenyi – 2019-07-09T15:59:15.960

5@GezaKerecsenyi As I understand it, a newline at the end of the source code is just a recommendation. See PEP8. – mypetlion – 2019-07-09T16:48:05.017

1

@GezaKerecsenyi Just a guideline

– mbomb007 – 2019-07-09T19:01:03.863

@wastl Thanks! Fixed. – TFeld – 2019-07-09T19:15:48.447

11

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

Kevin Cruijssen

Posted 2019-07-09T13:33:35.997

Reputation: 67 575

1Alternative 5 – Grimmy – 2019-07-10T11:22:12.123

11

RProgN 2, 3 bytes

1
0

Try it online!

I think this is valid?

dzaima

Posted 2019-07-09T13:33:35.997

Reputation: 19 048

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 – bigyihsuan – 2019-07-09T15:21:56.880

3@bigyihsuan that's what I'm guessing too; I don't know the language, I just recall it does stuff like this :p – dzaima – 2019-07-09T15:22:43.033

@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. – Kevin Cruijssen – 2019-07-09T15:48:52.130

I believe this is polyglot in tac on Linux.

– tsh – 2019-07-10T06:38:35.627

8

PHP, 9 bytes

<?=";;<";

Try it online!

Luis felipe De jesus Munoz

Posted 2019-07-09T13:33:35.997

Reputation: 9 639

3Actually, 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. – manassehkatz-Moving 2 Codidact – 2019-07-10T14:13:45.263

7

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

Erik the Outgolfer

Posted 2019-07-09T13:33:35.997

Reputation: 38 134

Isn't 121 also a valid trivial answer? – Teleporting Goat – 2019-07-10T09:51:01.177

@TeleportingGoat: No, because it has only two distinct characters – Oliver Hankeln – 2019-07-10T13:28:46.170

7

Excel, 9 bytes

=("))=" )

So many Parentheses.

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

william porter

Posted 2019-07-09T13:33:35.997

Reputation: 331

1Parentheses! (Lightbulb) I got stuck with the last character needing to be ". Well done! – Wernisch – 2019-07-11T08:34:36.540

Thanks! It was something I was trying to figure out as well, and then I remembered that parentheses would work. – william porter – 2019-07-12T15:08:08.417

6

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.

histocrat

Posted 2019-07-09T13:33:35.997

Reputation: 20 600

3I 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? – Damien – 2019-07-09T14:54:37.613

1Nice catch! I just like "doodling" during meetings by generating pictures using one-liners; xor was an early favorite. – histocrat – 2019-07-09T15:23:06.143

6

DOS/Windows Batch Language, 9 bytes

@echo @o@

user88009

Posted 2019-07-09T13:33:35.997

Reputation: 61

Welcome to Code Golf & Coding Challenges Stack Exchange, +1 for nice first post! – None – 2019-07-12T11:41:35.867

5

Ruby, 11 9 bytes

print:ptp

Try it online!

G B

Posted 2019-07-09T13:33:35.997

Reputation: 11 099

5

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.

Neil

Posted 2019-07-09T13:33:35.997

Reputation: 95 035

5

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.

jimmy23013

Posted 2019-07-09T13:33:35.997

Reputation: 34 042

it's smart answer – mazzy – 2019-07-10T06:48:01.673

1allowed because 0x0a != 0x0d != 0x31 :) – bigyihsuan – 2019-07-10T12:55:44.680

5

Bash (15 11 characters)

echo -n e-e

which prints out

e-e
  • -4 chars by not using |rev

Grzegorz Oledzki

Posted 2019-07-09T13:33:35.997

Reputation: 233

1

@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.

– Kevin Cruijssen – 2019-07-11T10:22:21.810

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 ... – pLumo – 2019-07-11T11:21:15.090

5

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.

Charlie

Posted 2019-07-09T13:33:35.997

Reputation: 11 448

5

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!

EdgyNerd

Posted 2019-07-09T13:33:35.997

Reputation: 1 106

Welcome to Code Golf SE! You can save a couple bytes by skipping the copy, like so.

– Khuldraeseth na'Barya – 2019-07-10T21:47:17.307

5

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.

Robin Ryder

Posted 2019-07-09T13:33:35.997

Reputation: 6 625

4

CJam, 7 bytes

'@'' _@

Try it online!

Luis Mendo

Posted 2019-07-09T13:33:35.997

Reputation: 87 464

4Pretty sure 0 1 0 is shorter and also has three distinct characters (I don't want to repost my Jelly approach :P). – Erik the Outgolfer – 2019-07-09T14:19:05.560

1@EriktheOutgolfer Well though!. But that's just like your answerm so I'll leave this as is – Luis Mendo – 2019-07-09T14:20:18.220

2Yeah, 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! – Erik the Outgolfer – 2019-07-09T14:24:53.400

4

C (gcc), 21 bytes


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

Try it online!

Johan du Toit

Posted 2019-07-09T13:33:35.997

Reputation: 1 524

1*Print the last, middle, and first character of your program's source code, in that order.* You're printing first, middle, last! – wastl – 2019-07-09T13:53:09.483

1oops, I just realized that. – Johan du Toit – 2019-07-09T13:54:13.647

1If there is an even number of characters, you need two middle characters. (sorry ...) – wastl – 2019-07-09T14:03:20.577

4

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.

Kevin Cruijssen

Posted 2019-07-09T13:33:35.997

Reputation: 67 575

4

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

ovs

Posted 2019-07-09T13:33:35.997

Reputation: 21 408

4

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.

Adám

Posted 2019-07-09T13:33:35.997

Reputation: 37 779

4

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.

jaaq

Posted 2019-07-09T13:33:35.997

Reputation: 499

1Depending 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. – Hoog – 2019-07-10T12:38:46.727

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. – jaaq – 2019-07-10T12:50:16.427

This prints a trailing newline but doesn't account for it. – None – 2019-07-15T13:40:46.397

Not sure if newlines count as whitespaces but I added the 2nd also 13-byte version. – jaaq – 2019-07-16T09:53:30.393

1Yes, newlines count as whitespace, just like tabs and spaces among others – Jo King – 2019-07-16T11:47:08.887

Thanks, removing the now redundant upper part of the submission. – jaaq – 2019-07-17T08:24:00.443

This gives the wrong middle character. I think you need to swap the ( and the previous space. – Ørjan Johansen – 2019-07-17T10:00:32.463

Thanks, fixed it. – jaaq – 2019-07-17T16:19:08.373

4

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!

user24343

Posted 2019-07-09T13:33:35.997

Reputation: 261

Seeing Chef programs makes me wonder what is the bare minimum for it. – bigyihsuan – 2019-07-11T13:35:43.977

@bigyihsuan see my edit – user24343 – 2019-07-12T15:45:11.573

You can remove all the "the"'s and make the program still work.

– None – 2019-07-13T04:15:12.857

I created a working program. (177 bytes)

– None – 2019-07-13T04:27:16.357

4

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.

TheOnlyMrCat

Posted 2019-07-09T13:33:35.997

Reputation: 1 079

3

Haskell, 17 bytes

main=putStr"\"Sm"

Try it online!

Damien

Posted 2019-07-09T13:33:35.997

Reputation: 2 407

3

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.

Kevin Cruijssen

Posted 2019-07-09T13:33:35.997

Reputation: 67 575

2@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. – Kevin Cruijssen – 2019-07-11T10:18:20.407

3

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)

Kevin Cruijssen

Posted 2019-07-09T13:33:35.997

Reputation: 67 575

3

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).

Post Rock Garf Hunter

Posted 2019-07-09T13:33:35.997

Reputation: 55 382

3

R, 11 bytes

cat("))c" )

Try it online!

Outputs ))c. Space added to make the number of characters odd: otherwise we would need to output 4 characters, and that would make the code longer anyway.

Robin Ryder

Posted 2019-07-09T13:33:35.997

Reputation: 6 625

Is this allowed? https://tio.run/##K/r/3y/R7/9/AA If so, you can cut it down to 3 bytes...

– Sumner18 – 2019-08-20T14:33:28.253

@Sumner18 I don't think it's allowed, because the initial [1] in the output counts. And maybe the trailing newline as well... – Robin Ryder – 2019-08-21T11:48:56.443

3

HQ9+ 4 characters

+AQ+

Explanation:

+ ; increment accumulator
A ; nop
Q ; print itself
+ ; increment accumulator

Helena

Posted 2019-07-09T13:33:35.997

Reputation: 321

1Code must consist of >= 3 distinct characters – Draco18s no longer trusts SE – 2019-07-09T18:32:52.610

@Draco18s thanks, I missed that part of the rule. I think I fixed it – Helena – 2019-07-09T18:54:28.357

3

Forth (gforth), 9 bytes

Prints an escape-supporting string.

.\"   ." 

Try it online


Also 9 bytes:

Prints three spaces.

 ."    " 

Try it online


9 bytes with Stack Underflow:

 ." .. ".

Try it online


The 2nd and 3rd solutions also work if you replace first quotations with ( and last quotes with ). Essentially, plenty of ways to do it in 9 bytes, but probably not any shorter.

Documentation

mbomb007

Posted 2019-07-09T13:33:35.997

Reputation: 21 944

3

MATLAB, 1315 bytes

disp(  ') d')

Outputs ) d

Previous version (15 bytes, less strict output):

'''';1;''''''''

Outputs '''

aaaaa says reinstate Monica

Posted 2019-07-09T13:33:35.997

Reputation: 381

I see now, now worries. – Post Rock Garf Hunter – 2019-07-11T00:40:51.047

Doesn't this output trailing whitespace? – Sanchises – 2019-07-14T12:13:42.797

@Sanchises nope, size(ans)==3 – aaaaa says reinstate Monica – 2019-07-14T16:03:29.230

Yes, but the actual output is ans =\n '''\n. Usually that's not a problem but this challenge seems to set a stricter standard. But then I may be interpreting the challenge wrong. – Sanchises – 2019-07-14T17:36:45.723

@Sanchises hm, i see. i might misunderstand what codegolf considers "output" then, your output seems to be literally the output, formatted by MATLAB – aaaaa says reinstate Monica – 2019-07-14T18:18:31.713

@Sanchises i have added shorter version, that seems to comply. Could you please check? I like the original more though :) – aaaaa says reinstate Monica – 2019-07-14T18:36:27.517

@aaaaaa disp also has a trailing newline. But maybe instead leave the old version and ask if that's OK. I guess this challenge is a little bit unclear because it seems to deviate from the standard but doesn't explicitly say so. – Sanchises – 2019-07-14T19:26:18.653

@Sanchises fprintf( ')(f') should work, as it outputs no trailing whitespace – aaaaa says reinstate Monica – 2019-07-14T20:55:04.263

Yeah I posted that as an Octave entry. – Sanchises – 2019-07-14T21:01:38.007

3

AsciiDots - 9 bytes

.---$'.$.

Output: .$.

The code starts with a ., ends with a ., and the middle character is a $. The single quote in the middle sets the dot print mode to simply read characters straight into the output stream.

It is possible that this could be made smaller, but I'm starting to doubt that it can. In order to print three characters, the single quote must be used, as the double quote would require an end to the string in order to output. However, this means that the single quote has to a) be followed by three characters and b) cannot be the center character. In order to crunch this down to seven bytes, I was considering trying to reuse the dot's start as one of the printed characters (sort of like AsciiDot's quine program). However, I found that the shortest sequence available for printing was ($' which would have had to print four characters in the space of three, or three characters in the space of four. I also tried some hacky alternative methods like trying to print the dot's value (which is 0) as one of the characters. While there may be some system that works, I've found these to be rather complex and large. Thus, I think that the above is the smallest solution. (I will update if I find something smaller)

DaCoolOne

Posted 2019-07-09T13:33:35.997

Reputation: 31

Welcome to Code Golf SE! I messed around with this for a few minutes and came to the same conclusion you did. Nice first post! – Khuldraeseth na'Barya – 2019-07-11T18:23:49.440

1

Alternative 9 bytes - /'$'-.[newline]\.Try it online!

– Alion – 2019-07-13T14:34:52.347

2

AppleScript, 4

1021

Outputs the last char (1), the middle chars (02), and the first char (1).

Any four-digit number with the same first and last digits and different middle digits works.

a stone arachnid

Posted 2019-07-09T13:33:35.997

Reputation: 1 053

2 Distinct characters are a requirement – Nick Kennedy – 2019-07-09T13:42:25.547

1@LuisfelipeDejesusMunoz Does this edit qualify? – a stone arachnid – 2019-07-10T04:00:29.227

2

Kotlin, 39 25 bytes

fun main(){print("}rf")
}

Try it online!

Edit: -14 bytes thanks to @daniero

Quinn

Posted 2019-07-09T13:33:35.997

Reputation: 1 153

main doesn't need parameters, you can drop 15 bytes – daniero – 2019-07-10T18:42:31.590

@daniero Cool, didn't realize that - thanks! (Only dropped 14 bytes and added an extra new line because if otherwise id have to print 4 characters) Also kinda cool that just by chance it still had the same output – Quinn – 2019-07-10T18:46:47.770

2

Stax, 5 bytes


.PPP

Run and debug it at staxlang.xyz!

The leading linefeed does nothing. .PP pushes the string PP, and the final P prints it with a trailing newline. The last character is P, the middle character is the first P, and the first character is a linefeed.

The implicit print's trailing linefeed invalidates the 4-byte solutions 1231 and .S.S (adapted from Weijun Zhou's quine).

Khuldraeseth na'Barya

Posted 2019-07-09T13:33:35.997

Reputation: 2 608

2

Python 3 12 13 bytes

input(r')ri')

mypetlion

Posted 2019-07-09T13:33:35.997

Reputation: 702

2

Forth (gforth), 13 bytes

: f ." ; :" ;

Try it online!

Code Explanation

: f         \ start a new word definition
  ." ; :" ; \ print "; :"
;           \ end the word definition

reffu

Posted 2019-07-09T13:33:35.997

Reputation: 1 361

1

You should add a footer, so people can actually see the output: https://tio.run/##S8svKsnQTU8DUf//WymkKegpKVgrWAGJ/2n/AQ

– mbomb007 – 2019-07-09T19:05:08.770

Fixed, Thanks for the heads up, I totally forgot to call the function – reffu – 2019-07-10T03:05:15.843

2

INTERCAL, 65 bytes

PLEASE,1<-#3DO,1SUB#1<-#246DON'TPARSE!!
DO READ OUT ,1
DO GIVE UP

Try it online!

Padding the second half of the program to make the output PPP seems to be shorter than printing multiple distinct characters.

PLEASE ,1 <- #3         Declare that the length of the uint16 array ,1 is 3.
DO ,1 SUB #1 <- #246    Make the first element of ,1 246. (The other elements are 0.)
DON'T PARSE!!           This statement is ignored and nonsense.
DO READ OUT ,1          Print ,1 using C-INTERCAL's "Turing Tape" I/O.
DO GIVE UP              End the program.

This one almost works for 35 bytes, but it prints a space before the first newline:


PLEASE       READ OUT#500DOGIVEUP

Unrelated String

Posted 2019-07-09T13:33:35.997

Reputation: 5 300

2

Charcoal, 7 bytes

←´←´´´X

Try it online! The final X could be any byte in the Charcoal code page except 0xFF and the two already in use. Works by printing the desired characters leftwards. Alternative approach, also 7 bytes:

←”y←←”y

Try it online! The final y could be any ASCII character but I picked y because of the symmetry. Works by printing two s leftwards so that the final character gets printed at the start of the output.

Neil

Posted 2019-07-09T13:33:35.997

Reputation: 95 035

2

PowerShell, 7 bytes

Another trivial solution. The first and the last lines contains LF.


"`nn"

Try it online!


PowerShell, 9 bytes

non-trivial, no byte sequence hacks. The first line contains LF only. The second line starts with a space.


 echo hh

Try it online!

mazzy

Posted 2019-07-09T13:33:35.997

Reputation: 4 832

1Code must consist of >= 3 unique characters. But: https://codegolf.stackexchange.com/a/188041/25180 – jimmy23013 – 2019-07-10T06:24:46.357

thanks. i removed trivial solution with 3 non-unique bytes – mazzy – 2019-07-10T06:33:55.180

2

Japt, 5 bytes

Inspired by my JavaScript solution.

N'a*N

Try it

Oliver

Posted 2019-07-09T13:33:35.997

Reputation: 7 160

1Ah-ha! I knew there had to be a 5 byter! Nice work. – Shaggy – 2019-07-11T21:04:21.603

2

Keg, 7 5 bytes

1\':'

This prints ''1, which are the respective characters.

No Try It Online available for Keg.

Here is an uninteresting 4-byte answer:

1231

user85052

Posted 2019-07-09T13:33:35.997

Reputation:

Good to see Keg standing up to 05AB1E in code golf! – Lyxal – 2019-07-11T23:44:10.367

would abca also work as an uninteresting answer? – Lyxal – 2019-07-13T05:18:28.860

Yes. I am trying to keep this simple, so I will not add this to the answer. – None – 2019-07-13T05:21:31.953

2

C++ (clang) (lambda expression), 17 bytes

[]{return "}n[";}

Try it online!


C++ (clang) (full program), 47 43 bytes


#import<ios>
int main() {std::puts("}n");}

Try it online!

 

Unfortunately had to leave an extra space in both of the solutions, to make them have an odd number of characters.

ruohola

Posted 2019-07-09T13:33:35.997

Reputation: 414

2

GolfScript, 7 5 bytes


".".

Try it online!

Explanation

     # A newline, just to hide the effect of the automatic trailing newline
"."  # The . character: the last and middle character
   . # Copy the character twice

# Implicitly output the whole stack without a delimiter.

# This returns ".." (the . character duplicated) and a trailing newline.

user85052

Posted 2019-07-09T13:33:35.997

Reputation:

There is a trailing newline at the end of the output; I'm not sure that's allowed. There is a boring 5 byte answer which only outputs 2 spaces and a newline: TIO.

– Robin Ryder – 2019-07-21T06:41:45.830

@RobinRyder No, it doesn't. It just outputs a single space and a newline. (TIO renders a newline as a space.) – None – 2020-01-09T10:48:56.450

2

Bitwise Cyclic Tag But Way Worse, 26 bytes

ÿ1111111122ÿ2000000002ÿ

Outputs ÿ ÿ ÿ. 26 bytes since ÿ is considered 2 bytes in UTF-8.

Try it Online!

EdgyNerd

Posted 2019-07-09T13:33:35.997

Reputation: 1 106

2

Cubix, 9 bytes


oN/
@oo

Try it online!

Reasonably boring one. Since the newlines in the first, middle and last positions are ignored by the interpreter the code wraps onto the following cube. Spaces could be used as well. eg oS/ @oo

  o
N / @ o
  o

Watch it run

  • N Pushs 10 (newline) onto the stack.
  • / redirects around the cube.
  • ooo outputs the newline 3 times.
  • /@ redirects again and halts the program

MickyT

Posted 2019-07-09T13:33:35.997

Reputation: 11 735

2

Haskell, 19 bytes


main=($LT)print--L

Try it online! Outputs LT<newline>.

Laikoni

Posted 2019-07-09T13:33:35.997

Reputation: 23 676

2

Lost, 21 bytes

v<<<<<>>>>>
>%?"v>@"@

Outputs: v>@.

Try it online or verify that it's deterministic.

Explanation:

Explanation of the language in general:

Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.

A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.

In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.

Explanation of the program:

All arrows, including the >v in the string, will lead the path towards the leading > on the second line. From there the program flow is as follows:

  • >: travel in an east/right direction
  • %: Put the safety 'off'. In a Lost program, an @ will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character @ would immediately terminate without doing anything. The % will turn this safety 'off', so when we now encounter an @ the program will terminate (if the safety is still 'on', the @ will be a no-op instead).
  • ?: Clean the top value on the stack. In some program flows it's highly likely we have a partial string on the stack, so we use this to wipe the stack clean of that potential string.
  • ": Start a string, which means it will push the integer code-points of the characters used (rather similar as the Whitespace program).
  • v>@: Push the code-points for these characters, being 118 62 64 respectively
  • ": We're done pushing code-points of this string
  • @: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the -A program argument flag these code-points will be output as characters instead.

Two things to note:

The top part could also have been v<<<<<<<< instead. Lost will wrap around to the other side when moving in a direction. So using v<<<<>>>> could be a slightly shorter path, and since it's the same byte-count anyway, why not use it. :)
Also, the first line contains an additional < and >. One of them is to avoid having the newline character as the middle of the program, which is rather difficult to output and would have only increased the byte-count. The second is to make the program length odd again, so we'd only have to output a single middle character instead of two.

Kevin Cruijssen

Posted 2019-07-09T13:33:35.997

Reputation: 67 575

1

Luis felipe De jesus Munoz

Posted 2019-07-09T13:33:35.997

Reputation: 9 639

My approach: alert(")"a") - sadly 2 Bytes longer with 13 Bytes – pixma140 – 2019-07-09T14:26:34.623

9 bytes using a similar trick you used in your PHP solution. – Oliver – 2019-07-10T19:33:17.380

1

Elm 0.19, 11 bytes

f()="\"\\f"

Prints "\f. See it working here.

O.O.Balance

Posted 2019-07-09T13:33:35.997

Reputation: 1 499

1

Runic Enchantments, 9 7 bytes

'@'':r@

Try it online!

-2 bytes by just using char literals. Outputs @''

Draco18s no longer trusts SE

Posted 2019-07-09T13:33:35.997

Reputation: 3 053

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!

Veskah

Posted 2019-07-09T13:33:35.997

Reputation: 3 580

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 – 2019-07-09T17:06:41.790

1@KevinCruijssen Yeah, didn't even think about that even though my current answer takes it into account. Purge inbound. – Veskah – 2019-07-09T17:15:16.817

2it seems to me that the output should be '''LF for this source code – mazzy – 2019-07-10T05:56:09.290

1@mazzy One day I'll post an answer that's up to spec. – Veskah – 2019-07-10T12:04:13.077

2

nice. 7 bytes, 3 unique chars :)

– mazzy – 2019-07-10T14:48:39.103

1

SNOBOL4 (CSNOBOL4), 19 bytes


	OUTPUT = 'D='
END

Try it online!

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

D=

Giuseppe

Posted 2019-07-09T13:33:35.997

Reputation: 21 077

1

APL (Dyalog Unicode), 9 bytes

⎕←'''''⎕'

Try it online!

Both the last and middle characters are ', while the first is .

J. Sallé

Posted 2019-07-09T13:33:35.997

Reputation: 3 233

1

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

Expired Data

Posted 2019-07-09T13:33:35.997

Reputation: 3 129

@jimmy23013 ok should be fixed now – Expired Data – 2019-07-09T15:44:52.120

1

Haskell, 17 bytes

main=putStr"\"Sm"

Try it online!

Post Rock Garf Hunter

Posted 2019-07-09T13:33:35.997

Reputation: 55 382

1

Identical with Damien's Haskell solution posted almost 2 hour 50 minutes earlier.

– manatwork – 2019-07-10T17:22:21.727

1

Lua, 31 13 bytes

print (')(p')

Prints )(p

Try it online!

ouflak

Posted 2019-07-09T13:33:35.997

Reputation: 925

1

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.

Neil

Posted 2019-07-09T13:33:35.997

Reputation: 95 035

1

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.

Neil

Posted 2019-07-09T13:33:35.997

Reputation: 95 035

1

Dodos, 22 bytes


	dot
	dot
0         0

Try it online!

Erik the Outgolfer

Posted 2019-07-09T13:33:35.997

Reputation: 38 134

1

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

Shaggy

Posted 2019-07-09T13:33:35.997

Reputation: 24 623

1

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.

Unrelated String

Posted 2019-07-09T13:33:35.997

Reputation: 5 300

Ah, you're right, I didn't read the spec closely enough. Thanks! – Unrelated String – 2019-07-09T20:11:51.810

1Coincidentally, I'd just added your original version as an alternative to my Japt solution - scrolled down and thought I'd found a polyglot! – Shaggy – 2019-07-09T20:37:59.643

1

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

Giuseppe

Posted 2019-07-09T13:33:35.997

Reputation: 21 077

1

Gema, 13 characters

\A=l\\\\@fail

Try it online!

manatwork

Posted 2019-07-09T13:33:35.997

Reputation: 17 865

1

Perl 5, 11 bytes

say "\"\\s"

Try it online!

Xcali

Posted 2019-07-09T13:33:35.997

Reputation: 7 671

1This 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 – 2019-07-11T12:29:05.423

@Abigail That still breaks the same rule about trailing whitespace. – Chris – 2019-07-30T10:24:26.827

1

HTML, 4 bytes

^db^

^<X>_<X>^

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

First one also worked as PHP or Text.

tsh

Posted 2019-07-09T13:33:35.997

Reputation: 13 072

1

It's my bad that not creating a page for txeT before this challenge...

– tsh – 2019-07-10T03:01:41.757

1

dc, 9 characters

[PP]P91aP

Sample run:

bash-5.0$ dc -e '[PP]P91aP'
PP[

Try it online!

manatwork

Posted 2019-07-09T13:33:35.997

Reputation: 17 865

1

MarioLANG, 53 bytes

+>(-[!)
+"===#+
++
++
++
++
++
 +
)!)  <...
=#==="==+

Try it online!

Output: +++. The 27th character is one of the + characters in the second column of the code.

Charlie

Posted 2019-07-09T13:33:35.997

Reputation: 11 448

1

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.

Stephen

Posted 2019-07-09T13:33:35.997

Reputation: 12 293

1

Bash, 9 11 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

William

Posted 2019-07-09T13:33:35.997

Reputation: 11

1Welcome to codegolf.se. It should print in the order of the last, middle and first character, o e for your current code. – jimmy23013 – 2019-07-10T15:19:41.800

2Also “Output must not contain any trailing whitespace.” I'm afraid your contains, actually outputs 4 characters instead of 3. – manatwork – 2019-07-10T15:26:01.847

Now is correct, but became exact copy of Grzegorz Oledzki's Bash solution posted yesterday.

– manatwork – 2019-07-11T13:06:04.993

1

attinat

Posted 2019-07-09T13:33:35.997

Reputation: 3 495

1

PHP, 11 bytes

<?=';\\<';;

Try it online!

John

Posted 2019-07-09T13:33:35.997

Reputation: 181

1

BitCycle, 5 bytes


11!1

Try it online!

Outputs 11 with a trailing newline. Only the first pair of 1s is actually printed.

Jo King

Posted 2019-07-09T13:33:35.997

Reputation: 38 234

1

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.

Charlie

Posted 2019-07-09T13:33:35.997

Reputation: 11 448

1

Perl 5, 11 bytes


 say '; ';

Try it online!

Note the initial newline and the trailing space. Outputs

; 

Chris

Posted 2019-07-09T13:33:35.997

Reputation: 1 313

1

SmileBASIC, 7 bytes

?":b?":

Output: :b?

(Probably works in most BASIC dialects) The middle character can be anything except ", LF, and CR.

12Me21

Posted 2019-07-09T13:33:35.997

Reputation: 6 110

1

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

dumetrulo

Posted 2019-07-09T13:33:35.997

Reputation: 131

1

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!

EdgyNerd

Posted 2019-07-09T13:33:35.997

Reputation: 1 106

1Sure it matched the requirement “Code must consist of >= 3 unique characters.”? – manatwork – 2019-07-12T16:08:13.720

Oh yeah, fixed it – EdgyNerd – 2019-07-12T16:45:31.633

Oh, didn’t realise that. Does it auto fill the last byte of output to 8 bits? – EdgyNerd – 2019-07-13T07:55:59.670

1

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.

Sok

Posted 2019-07-09T13:33:35.997

Reputation: 5 592

1

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].

GammaFunction

Posted 2019-07-09T13:33:35.997

Reputation: 2 838

1

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.

Sanchises

Posted 2019-07-09T13:33:35.997

Reputation: 8 530

1

Python 2, 12 bytes 11 bytes

Placeholder to make the leading newline visible

print"\"t"

he77789

Posted 2019-07-09T13:33:35.997

Reputation: 111

1

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 – 2019-07-15T10:19:53.477

1It also prints an extra newline, which is not allowed. – jimmy23013 – 2019-07-15T11:50:09.020

This 11 byte solution may be valid. Do you agree? @jimmy23013 – Expired Data – 2019-07-15T14:27:30.267

@ExpiredData Yes it works. – jimmy23013 – 2019-07-15T14:51:19.843

1

Rust (closure), 9 bytes

|| ";;|";

Try it online!


Rust (full program), 25 bytes

fn main(){print!("}}if")}

Try it online!

ruohola

Posted 2019-07-09T13:33:35.997

Reputation: 414

1

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!

Kenneth Taylor

Posted 2019-07-09T13:33:35.997

Reputation: 183

1

Ohm v2, 5 bytes

…Lo…L

Try it online!

Cinaski

Posted 2019-07-09T13:33:35.997

Reputation: 1 588

1

ink, 5 bytes


/a//

Prints /a and a newline

Try it online!

Sara J

Posted 2019-07-09T13:33:35.997

Reputation: 2 576

1

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

Krzysztof Szewczyk

Posted 2019-07-09T13:33:35.997

Reputation: 3 819

1

6502, 17/21 bytes

6502: 17 bytes if running in zero page

For initial testing I used Py65, a 6502-based microcomputer simulator written in Python. Starting Py65 with the command-line parameter -o ff moves the character output port to zero page address $FF, shaving three bytes from the code.

The program must be loaded and run at $0000, to guarantee outputing the correct three characters (in order) from the program with values 00 B5 A5.

Here are the program bytes and their respective disassembly view in Py65:

.mem 0000:0010
0000:  a5  10  85  ff  a9  11  4a  aa  b5  00  85  ff  a5  00  85  ff  00

.d 0000:0010
$0000  a5 10     LDA $10
$0002  85 ff     STA $ff
$0004  a9 11     LDA #$11
$0006  4a        LSR A
$0007  aa        TAX
$0008  b5 00     LDA $00,X
$000a  85 ff     STA $ff
$000c  a5 00     LDA $00
$000e  85 ff     STA $ff
$0010  00        BRK

6502: 21 bytes if running outside zero page

Four additional bytes are required to allow the program to run outside of zero page. Three of the those bytes are the change in the LDA (load accumulator) instructions from zero page to absolute addressing. The fourth is the addition of a NOP (no operation) instruction, to maintain an odd number of bytes in the program.

This version of the program must be loaded and run at $0300, to guarantee outputing the correct three characters (in order) from the program with values 00 00 AD.

Here are the program bytes (character values) and their respective disassembly view:

.mem 0300:0314
0300:  ad  14  03  85  ff  a9  15  4a  aa  bd  00  03  85  ff  ad  00  03  85
0312:  ff  ea  00

.d 0300:0314
$0300  ad 14 03  LDA $0314
$0303  85 ff     STA $ff
$0305  a9 15     LDA #$15
$0307  4a        LSR A
$0308  aa        TAX
$0309  bd 00 03  LDA $0300,X
$030c  85 ff     STA $ff
$030e  ad 00 03  LDA $0300
$0311  85 ff     STA $ff
$0313  ea        NOP
$0314  00        BRK

6502: 21 bytes if running on an Apple II

We've come this far, so let's plop this baby on an Apple II. I don't normally tote around my Apple //c anymore, so I used a2ix on my Android phone.

Instead of sending characters to an addressed port, they will go to COUT (character output), a routine in system ROM.

$0300 is the usual spot for small assembly routines, so that's where I'll enter and list it. Running it yields a flashing space (60), inverse N (0E), and a normal " (A2). On the Apple II, ASCII characters are remapped across the 256-character range to achieve different character effects in text mode.

*300: A2 14 20 0E 03 A9 15 4A AA 20 0E 03 A2 00 BD 00 03 20 ED FD 60

*300L

0300-   A2 14       LDX   #$14
0302-   20 0E 03    JSR   $030E
0305-   A9 15       LDA   #$15
0307-   4A          LSR
0308-   AA          TAX
0309-   20 0E 03    JSR   $030E
030C-   A2 00       LDX   #$00
030E-   BD 00 03    LDA   $0300,X
0311-   20 ED FD    JSR   $FDED
0314-   60          RTS

Relocating this to a free area of zero page (good luck!) would not yield any byte savings. While the absolute indexed LDA (load accumulator) at $030E could be switched to its zero page indexed counterpart to save one byte, an NOP (no operation) would have to be added to avoid additional code to support print two middle characters.

lee

Posted 2019-07-09T13:33:35.997

Reputation: 91

1

05AB1E, 5 bytes

×'×3×

Try it online!

×   push a string of nothing, repeated nothing times (in other words, push an empty string)
'×  push "×"
3×  push "×", repeated 3 times
    implicitly print top of stack

Dorian

Posted 2019-07-09T13:33:35.997

Reputation: 1 521

1

AWK, 17 bytes

BEGIN{print"}iB"}

Try it online!

rootbeersoup

Posted 2019-07-09T13:33:35.997

Reputation: 111

1

naz, 28 24 bytes

0a9a3a9m3a2o0a0a0a0a0m2o

Explanation

0a9a3a9m3a2o # Output "o" twice
0a0a0a0a     # Padding bytes
0m2o         # Output "0" twice

Original 28-byte solution: 0a9a3a9m3a1o0a0a0a9s5s1o0m2o

sporeball

Posted 2019-07-09T13:33:35.997

Reputation: 461

1

W, 5 bytes


'+:+

Explanation

     % Newline (no-op)
'+   % The addition operator
  :+ % Multiply the character twice
     % Print with a newline
```

user85052

Posted 2019-07-09T13:33:35.997

Reputation:

0

C#, 71 bytes

public class P{public static void Main(){System.Console.Write("pa}");}}

Try Online
I don't think I need to explain anything here

canttalkjustcode

Posted 2019-07-09T13:33:35.997

Reputation: 131

0

x86-64 (Mac OS), 35 bytes

b8 04 00 00 02 bf 01 00 00 00 48 be 20 00 00 00
00 00 00 00 ba 03 00 00 00 0f 05 48 31 c0 c3 00
b8 00 b8

can be disassembled to:

[bits 64]

section .text
  global _main

_main:
  mov rax, 0x2000004
  mov rdi, 1
  mov rsi, x
  mov rdx, 3
  syscall
  xor rax, rax
  ret

section .data
  x: db 184, 0, 184

and compiled with:

$ nasm -fmacho64 FILE.asm
$ ld -fSystem FILE.asm

then run

$ ./a.out
<0xb8><0x00><0xb8>

maviek

Posted 2019-07-09T13:33:35.997

Reputation: 1

0

Python 3, 13 bytes

print(')\'p')

Try it online!

Dat

Posted 2019-07-09T13:33:35.997

Reputation: 879

0

Python 3, 13 bytes

This should suffice. Although it has a new line at the end of the output. There is a space in between print and '(' to make the total count of characters odd.

print (')(p')

Try it online!

Divy

Posted 2019-07-09T13:33:35.997

Reputation: 51