Golf you a quine for great good!

204

60

Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

  • Smallest code (in bytes)
  • Most obfuscated/obscure solution
  • Using esoteric/obscure languages
  • Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&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(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.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(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
getAnswers();var SCORE_REG=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery('<i>'+a.language+'</i>').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}
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> 

Rafe Kettler

Posted 2011-01-28T00:34:05.293

Reputation: 2 269

4Do you not mean, "Golf you a quine for greater good!"? – Mateen Ulhaq – 2011-05-03T02:49:07.960

51@muntoo it's a play on "Learn you a Haskell for Great Good". – Rafe Kettler – 2011-05-03T02:52:14.103

Answers

107

Hexagony, side-length 17 16, 816 705 bytes

180963109168843880558244491673953327577233938129339173058720504081484022549811402058271303887670710274969455065557883702369807148960608553223879503892017157337685576056512546932243594316638247597075423507937943819812664454190530214807032600083287129465751195839469777849740055584043374711363571711078781297231590606019313065042667406784753422844".".>.@.#.#.#.#.#.#.#.>.(...........................<.".......".".>./.4.Q.;.+.<.#.>...........................<.".....".".>.#.#.>.N.2.'.\.>.............=.=......._.<.".....".".>.>.;.'.=.:.\.>.......................<."...".".>.\.'.%.'.<.#.>..............._.....<."...".".>.#.#.>.<.#.>...............=.=.<.".".".>.#.\.'.R./.>.................<.".!.........../.>.

Try it online!

This is what it looks like unfolded:

                1 8 0 9 6 3 1 0 9 1 6 8 8 4 3 8
               8 0 5 5 8 2 4 4 4 9 1 6 7 3 9 5 3
              3 2 7 5 7 7 2 3 3 9 3 8 1 2 9 3 3 9
             1 7 3 0 5 8 7 2 0 5 0 4 0 8 1 4 8 4 0
            2 2 5 4 9 8 1 1 4 0 2 0 5 8 2 7 1 3 0 3
           8 8 7 6 7 0 7 1 0 2 7 4 9 6 9 4 5 5 0 6 5
          5 5 7 8 8 3 7 0 2 3 6 9 8 0 7 1 4 8 9 6 0 6
         0 8 5 5 3 2 2 3 8 7 9 5 0 3 8 9 2 0 1 7 1 5 7
        3 3 7 6 8 5 5 7 6 0 5 6 5 1 2 5 4 6 9 3 2 2 4 3
       5 9 4 3 1 6 6 3 8 2 4 7 5 9 7 0 7 5 4 2 3 5 0 7 9
      3 7 9 4 3 8 1 9 8 1 2 6 6 4 4 5 4 1 9 0 5 3 0 2 1 4
     8 0 7 0 3 2 6 0 0 0 8 3 2 8 7 1 2 9 4 6 5 7 5 1 1 9 5
    8 3 9 4 6 9 7 7 7 8 4 9 7 4 0 0 5 5 5 8 4 0 4 3 3 7 4 7
   1 1 3 6 3 5 7 1 7 1 1 0 7 8 7 8 1 2 9 7 2 3 1 5 9 0 6 0 6
  0 1 9 3 1 3 0 6 5 0 4 2 6 6 7 4 0 6 7 8 4 7 5 3 4 2 2 8 4 4
 " . " . > . @ . # . # . # . # . # . # . # . > . ( . . . . . .
  . . . . . . . . . . . . . . . . . . . . . < . " . . . . . .
   . " . " . > . / . 4 . Q . ; . + . < . # . > . . . . . . .
    . . . . . . . . . . . . . . . . . . . . < . " . . . . .
     " . " . > . # . # . > . N . 2 . ' . \ . > . . . . . .
      . . . . . . . = . = . . . . . . . _ . < . " . . . .
       . " . " . > . > . ; . ' . = . : . \ . > . . . . .
        . . . . . . . . . . . . . . . . . . < . " . . .
         " . " . > . \ . ' . % . ' . < . # . > . . . .
          . . . . . . . . . . . _ . . . . . < . " . .
           . " . " . > . # . # . > . < . # . > . . .
            . . . . . . . . . . . . = . = . < . " .
             " . " . > . # . \ . ' . R . / . > . .
              . . . . . . . . . . . . . . . < . "
               . ! . . . . . . . . . . . / . > .
                . . . . . . . . . . . . . . . .

Ah well, this was quite the emotional rollercoaster... I stopped counting the number of times I switched between "haha, this is madness" and "wait, if I do this it should actually be fairly doable". The constraints imposed on the code by Hexagony's layout rules were... severe.

It might be possible to reduce the side-length by 1 or 2 without changing the general approach, but it's going to be tough (only the cells with # are currently unused and available for the decoder). At the moment I also have absolutely no ideas left for how a more efficient approach, but I'm sure one exists. I'll give this some thought over the next few days and maybe try to golf off one side-length, before I add an explanation and everything.

Well at least, I've proven it's possible...

Some CJam scripts for my own future reference:

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

51Dear pete what is this. – Conor O'Brien – 2016-02-26T23:05:21.527

2How long did it take to make this? – Adnan – 2016-02-26T23:13:38.617

3@AandN I've been playing around with concepts for a general "template" since yesterday now and then (that didn't involve any actual testing... just typing up some stuff on a 7x7 grid and seeing if it might work... I discarded probably half a dozen approaches already there). The actual coding then took this evening... maybe 3 hours, I'd say. – Martin Ender – 2016-02-26T23:15:59.713

Well, my guess of 23 was a bit off... :P – Rɪᴋᴇʀ – 2016-02-26T23:23:22.757

@RikerW Hey, I'm not done yet! (That said, yes it was.) – Martin Ender – 2016-02-26T23:23:50.667

Are you done yet? – Rɪᴋᴇʀ – 2016-04-03T20:43:51.603

@EasterlyIrk Ummm, not quite... I've got a couple of ideas, but I haven't found the motivation yet to sit down for another 3-hour Hexagony session to try them out. :P – Martin Ender – 2016-04-03T20:46:05.010

11Words can't explain how astonished I am when seeing this in action with Esoteric IDE step by step...

To whom may want to understand this, this Hexagon encodes the "decoder" part into an integer which is printed with ! and then with a mirror / on the 2nd last line it enters the decoder to print the decoder code to complete the quine.

This has a miraculous use of < and > which reads the multiline very big integer and built the area for storing the decoder.

I'd really love to know what "dozens of approaches" are being considered? – Sunny Pun – 2016-10-24T05:48:59.640

3Explanation? --- – MD XF – 2017-06-16T04:21:06.203

79

MySQL, 167 characters

SELECT REPLACE(@v:='SELECT REPLACE(@v:=\'2\',1+1,REPLACE(REPLACE(@v,\'\\\\\',\'\\\\\\\\\'),\'\\\'\',\'\\\\\\\'\'));',1+1,REPLACE(REPLACE(@v,'\\','\\\\'),'\'','\\\''));

That's right. :-)

I really did write this one myself. It was originally posted at my site.

TehShrike

Posted 2011-01-28T00:34:05.293

Reputation: 995

72

GolfScript, 2 bytes

1

(note trailing newline) This pushes the number 1 onto the stack. At the end of the program, GolfScript prints out all items in the stack (with no spaces in between), then prints a newline.

This is a true quine (as listed in the question), because it actually executes the code; it doesn't just "read the source file and print it" (unlike the PHP submission).


For another example, here's a GolfScript program to print 12345678:

9,(;
  1. 9: push 9 to the stack
  2. ,: consume the 9 as an argument, push the array [0 1 2 3 4 5 6 7 8] to the stack
  3. (: consume the array as an argument, push the array [1 2 3 4 5 6 7 8] and the item 0 to the stack
  4. ;: discard the top item of the stack

The stack now contains the array [1 2 3 4 5 6 7 8]. This gets written to standard output with no spaces between the elements, followed by a newline.

Chris Jester-Young

Posted 2011-01-28T00:34:05.293

Reputation: 4 464

78Technically, 1 is not a quine in GolfScript: it outputs 1\n, where \n denotes a newline. However, the two-char program 1\n is a quine. – Ilmari Karonen – 2012-02-03T08:27:39.457

10@Pseudonym a quine is literally a program which prints its own source. I don't think there are any arbitrary restrictions on "structure". – Hugo Zink – 2015-09-24T11:07:23.523

@Rokk When Hofstader coined the term, he was specifically thinking of Quine's paradox. "Self-replicating program" or "self-copying program" is the more general term. – Pseudonym – 2015-09-24T11:11:51.043

@Pseudonym I see, thanks for the explanation. – Hugo Zink – 2015-09-24T11:14:36.993

@Pseudonym This program doesn't just print its own source. I've expanded with an explanation. – Chris Jester-Young – 2015-09-24T11:37:50.193

@ChrisJester-Young I don't dispute that it's a real, non-cheating self-replicating program. I'm just saying it's not a quine, which is a certain kind of self-replicating program. – Pseudonym – 2015-09-24T12:12:25.697

18Or PowerShell, or PHP :-) – Joey – 2011-01-28T09:54:27.763

19The one-char program \n probably also is? – Lynn – 2013-08-23T14:51:02.620

No, Ilmari, even that is not a quine. A quine is not just a program which prints its own source, it has to have a specific structure to be a quine. – Pseudonym – 2014-02-12T05:59:45.270

2I doubt this is allowed, because on what counts as a valid quine, it says one part of the script has to encode another. – MilkyWay90 – 2018-11-09T15:14:45.570

This program is self-referencing because the program directly says that the exact source string should be printed to the console. The content of the reference is identical to the complete source code before it gets printed out. Therefore this program is a cheating quine. – None – 2019-10-04T01:36:13.770

6You didn't go back in time and give the inventor the idea to invent GolfScript, did you? – Mateen Ulhaq – 2011-05-03T02:38:31.560

72

Brain-Flak, 9.8e580 1.3e562 9.3e516 12818 11024 4452 4332 4240 4200 4180 3852 3656 3616 3540 2485 + 3 = 2488 bytes

Now fits in the observable universe!

(())(()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(()()()()())(())(())(())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(()()()()())(())(())(())(())(())(())(()())(())(())(())(()())(()()()())(())(()()()()())(()())(()())(()())(()()())(())(()())(())(()()()()())(()())(()()()()())(())(())(())(())(())(()())(())(())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()())(()())(()())(()())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(()()())(()())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(())(())(()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(()()())(())(()()())(())(())(())(()())(()()())(()())(())(()()()()())(()())(())(()()())(())(()()()()())(())(())(())(()()())(())(())(())(()())(())(()())(()()()())(())(())(()()()()())(()())(()())(())(()()())(())(())(())(())(()()())(()())(())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()())(())(()()()()())(()()()()())(())(()()())(())(())(()())(())(()()()()())(())(()()()()())(())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(())(()()()()())(())(())(())(()())(())(()()()()())(())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()()()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(())(()())(()()()())(())(())(()())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()())(()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(()()())(())(())(()())(())(())(()()()()())(()()()())(()())(()())(()()())(())(()())(())(()()()()())(()())(()()()()())(())(())(())(()()()())(()()()())(()())([[]]){({}()<(([{}]())<{({}())<>(((((()()()()()){}){}){}())[()])<>{({}())<>{}({}(((()()()){}())){}{})<>{({}())<>({}(((()()()()()){})){}{}())<>{{}<>({}(((()()()()){}){}){})(<>)}}<>(({})[()()])<>}}{}<>({}(<()>)<><{({}<>)<>}<>>){({}<>)<>}{}(<>)<>{({}<>)<>}{}(((((((()()()()()){}){}){}))()))>){({}()<((({}[()])()))>)}{}<>{({}<>)<>}{}>)}{}<>{({}<>)<>}<>

Try it online!


Explanation

This Quine works like most Quines in esoteric languages; it has two parts an encoder and a decoder. The encoder is all of the parentheses at the beginning and the decoder is the more complex part at the very end.

A naive way of encoding the program would be to put the ASCII value of every character in the decoder to the stack. This is not a very good idea because Brain-Flak only uses 8 characters (()<>[]{}) so you end up paying quite a few bytes to encode very little information. A smarter idea, and the one used up until now is to assign each of the 8 braces to an much smaller number (1-8) and convert these to the ASCII values with our decoder. This is nice because it costs no more than 18 bytes to encode a character as opposed to the prior 252.

However this program does neither. It relies on the fact that Brain-Flak programs are all balanced to encode the 8 braces with the numbers up to 5. It encodes them as follows.

(       -> 2
<       -> 3
[       -> 4
{       -> 5
),>,],} -> 1

All the close braces are assigned 1 because we can use context to determine which of them we need to use in a particular scenario. This may sound like a daunting task for a Brain-Flak program, but it really is not. Take for example the following encodings with the open braces decoded and the close braces replaced with a .:

(.
((..
<([.{...

Hopefully you can see that the algorithm is pretty simple, we read left to right, each time we encounter a open brace we push its close brace to an imaginary stack and when we encounter a . we pop the top value and put it in place of the .. This new encoding saves us an enormous number of bytes in the encoder while only losing us a handful of bytes on the decoder.

Low level explanation

Work in progress

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

25I think you win for longest solution to a code-golf challenge... – Mego – 2016-10-04T10:40:12.720

18Just made the largest single golf in the history of PPCG Nope. 9.8e580 is still impressive though. – Dennis – 2016-10-04T17:15:57.933

3... very big golf ... – Destructible Lemon – 2016-12-09T23:21:55.737

3I think you win for most bytes cut off – Christopher – 2017-02-25T02:18:20.723

@Dennis isn't this a larger golf? or is it invalid

– ASCII-only – 2018-05-07T23:52:44.817

@ASCII-only That's only 2.1 × 10^7417. The other one is 10^(5.2 × 10^152). – Dennis – 2018-05-08T01:47:48.697

@Dennis Ah. the complexity of the expression was confusing me >_> – ASCII-only – 2018-05-08T01:59:38.710

1From 9.8 * 10 ^ 580 to 2000. Wow – MilkyWay90 – 2019-03-06T23:25:14.327

Did you manage to make any progress on the low level explanation? – MilkyWay90 – 2019-07-09T16:42:14.393

@MilkyWay90 I was writing a memory visualizer for this but kind of got bored of it. At this point I only have a hazy recollection of how this even works. – Post Rock Garf Hunter – 2019-07-09T16:43:26.377

@SriotchilismO'Zaic Okay, thanks! – MilkyWay90 – 2019-07-09T16:44:05.447

69

Prelude, 5157 4514 2348 1761 1537 664 569 535 423 241 214 184 178 175 169 148 142 136 133 bytes

Thanks to Sp3000 for saving 3 bytes.

This is rather long... (okay, it's still long ... at least it's beating the shortest known Brainfuck C# quine on this challenge now) but it's the first quine I discovered myself (my Lua and Julia submissions are really just translations of standard quine techniques into other languages) and as far as I'm aware no one has written a quine in Prelude so far, so I'm actually quite proud of this. :)

7( -^^^2+8+2-!( 6+ !
  ((#^#(1- )#)8(1-)8)#)4337435843475142584337433447514237963742423434123534455634423547524558455296969647344257)

That large number of digits is just an encoding of the core code, which is why the quine is so long.

The digits encoding the quine have been generated with this CJam script.

This requires a standard-compliant interpreter, which prints characters (using the values as character codes). So if you're using the Python interpreter you'll need to set NUMERIC_OUTPUT = False.

Explanation

First, a few words about Prelude: each line in Prelude is a separate "voice" which manipulates its own stack. These stacks are initialised to an infinite number of 0s. The program is executed column by column, where all commands in the column are executed "simultaneously" based on the previous stack states. Digits are pushed onto the stack individually, so 42 will push a 4, then a 2. There's no way to push larger numbers directly, you'll have to add them up. Values can be copied from adjacent stacks with v and ^. Brainfuck-style loops can be introduced with parentheses. See the link in the headline for more information.

Here is the basic idea of the quine: first we push loads of digits onto the stack which encode the core of the quine. Said core then takes those digits,decodes them to print itself and then prints the digits as they appear in the code (and the trailing )).

This is slightly complicated by the fact that I had to split the core over multiple lines. Originally I had the encoding at the start, but then needed to pad the other lines with the same number of spaces. This is why the initial scores were all so large. Now I've put the encoding at the end, but this means that I first need to skip the core, then push the digits, and jump back to the start and do the printing.

The Encoding

Since the code only has two voices, and and adjacency is cyclic, ^ and v are synonymous. That's good because v has by far the largest character code, so avoiding it by always using ^ makes encoding simpler. Now all character codes are in the range 10 to 94, inclusive. This means I can encode each character with exactly two decimal digits. There is one problem though: some characters, notably the linefeed, have a zero in their decimal representation. That's a problem because zeroes aren't easily distinguishable from the bottom of the stack. Luckily there's a simple fix to that: we offset the character codes by 2, so we have a range from 12 to 96, inclusive, that still comfortably fits in two decimal digits. Now of all the characters that can appear in the Prelude program, only 0 has a 0 in its representation (50), but we really don't need 0 at all. So that's the encoding I'm using, pushing each digit individually.

However, since we're working with a stack, the representations are pushed in reverse. So if you look at the end of the encoding:

...9647344257

Split into pairs and reverse, then subtract two, and then look up the character codes:

57 42 34 47 96
55 40 32 45 94
 7  (     -  ^

where 32 is corresponds to spaces. The core does exactly this transformation, and then prints the characters.

The Core

So let's look at how these numbers are actually processed. First, it's important to note that matching parentheses don't have to be on the same line in Prelude. There can only be one parenthesis per column, so there is no ambiguity in which parentheses belong together. In particular, the vertical position of the closing parenthesis is always irrelevant - the stack which is checked to determine whether the loop terminates (or is skipped entirely) will always be the one which has the (.

We want to run the code exactly twice - the first time, we skip the core and push all the numbers at the end, the second time we run the core. In fact, after we've run the core, we'll push all those numbers again, but since the loop terminates afterwards, this is irrelevant. This gives the following skeleton:

7(
  (                   )43... encoding ...57)

First, we push a 7 onto the first voice - if we don't do this, we'd never enter the loop (for the skeleton it's only important that this is non-zero... why it's specifically 7 we'll see later). Then we enter the main loop. Now, the second voice contains another loop. On the first pass, this loop will be skipped because the second stack is empty/contains only 0s. So we jump straight to the encoding and push all those digits onto the stack. The 7 we pushed onto the first stack is still there, so the loop repeats.

This time, there is also a 7 on the second stack, so we do enter loop on the second voice. The loop on the second voice is designed such that the stack is empty again at the end, so it only runs once. It will also deplete the first stack... So when we leave the loop on the second voice, we push all the digits again, but now the 7 on the first stack has been discarded, so the main loop ends and the program terminates.

Next, let's look at the first loop in the actual core. Doing things simultaneously with a ( or ) is quite interesting. I've marked the loop body here with =:

-^^^2+8+2-!
(#^#(1- )#)
 ==========

That means the column containing ( is not considered part of the loop (the characters there are only executed once, and even if the loop is skipped). But the column containing the ) is part of the loop and is ran once on each iteration.

So we start with a single -, which turns the 7 on the first stack into a -7... again, more on that later. As for the actual loop...

The loop continues while the stack of digits hasn't been emptied. It processes two digits at a time,. The purpose of this loop is to decode the encoding, print the character, and at the same time shift the stack of digits to the first voice. So this part first:

^^^
#^#

The first column moves the 1-digit over to the first voice. The second column copies the 10-digit to the first voice while also copying the 1-digit back to the second voice. The third column moves that copy back to the first voice. That means the first voice now has the 1-digit twice and the 10-digit in between. The second voice has only another copy of the 10-digit. That means we can work with the values on the tops of the stacks and be sure there's two copies left on the first stack for later.

Now we recover the character code from the two digits:

2+8+2-!
(1- )#

The bottom is a small loop that just decrements the 10-digit to zero. For each iteration we want to add 10 to the top. Remember that the first 2 is not part of the loop, so the loop body is actually +8+2 which adds 10 (using the 2 pushed previously) and the pushes another 2. So when we're done with the loop, the first stack actually has the base-10 value and another 2. We subtract that 2 with - to account for the offset in the encoding and print the character with !. The # just discards the zero at the end of the bottom loop.

Once this loop completes, the second stack is empty and the first stack holds all the digits in reverse order (and a -7 at the bottom). The rest is fairly simple:

( 6+ !
8(1-)8)#

This is the second loop of the core, which now prints back all the digits. To do so we need to 48 to each digit to get its correct character code. We do this with a simple loop that runs 8 times and adds 6 each time. The result is printed with ! and the 8 at the end is for the next iteration.

So what about the -7? Yeah, 48 - 7 = 41 which is the character code of ). Magic!

Finally, when we're done with that loop we discard the 8 we just pushed with # in order to ensure that we leave the outer loop on the second voice. We push all the digits again and the program terminates.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

1Listening to Hello World in Fugue right now... pretty catchy. – Robert Fraser – 2015-04-29T03:29:29.123

19Martin, you gotta stop somewhere. – seequ – 2016-02-25T21:12:09.623

4I love that this has over 5000 bytes golfed overall, plus an acknowledgement to Sp3000 for saving 3 of them. – Kamil Drakari – 2018-05-02T02:44:23.507

2@KamilDrakari Those were the last 3 bytes though, so it's quite a big deal. ;) – Martin Ender – 2018-05-02T06:58:35.920

62

Hexagony, side length 11, 314 bytes

164248894991581511673077637999211259627125600306858995725520485910920851569759793601722945695269172442124287874075294735023125483.....!/:;.........)%'=a':\....................\...................\..................\.................\................\...............\..............\..$@.........\$><>'?2='%.<\:;_;4Q

Try it online!


Older version:

Hexagony, side length 11, 330 bytes

362003511553420961423766261426252539048636523959468260999944549820033581478284471415809677091006384959302453627348235790194699306179..../:{;+'=1P'%'a{:..\.....................\...................\..................\.................\................\...............\..............\.............\!$><........\..@>{?2'%<......:;;4Q/

Try it online!

Encoder: Try it online!

The program is roughly equivalent to this Python code: Try it online!

Unfolded code:

           3 6 2 0 0 3 5 1 1 5 5
          3 4 2 0 9 6 1 4 2 3 7 6
         6 2 6 1 4 2 6 2 5 2 5 3 9
        0 4 8 6 3 6 5 2 3 9 5 9 4 6
       8 2 6 0 9 9 9 9 4 4 5 4 9 8 2
      0 0 3 3 5 8 1 4 7 8 2 8 4 4 7 1
     4 1 5 8 0 9 6 7 7 0 9 1 0 0 6 3 8
    4 9 5 9 3 0 2 4 5 3 6 2 7 3 4 8 2 3
   5 7 9 0 1 9 4 6 9 9 3 0 6 1 7 9 . . .
  . / : { ; + ' = 1 P ' % ' a { : . . \ .
 . . . . . . . . . . . . . . . . . . . . \
  . . . . . . . . . . . . . . . . . . . \ 
   . . . . . . . . . . . . . . . . . . \  
    . . . . . . . . . . . . . . . . . \   
     . . . . . . . . . . . . . . . . \    
      . . . . . . . . . . . . . . . \     
       . . . . . . . . . . . . . . \      
        . . . . . . . . . . . . . \       
         ! $ > < . . . . . . . . \        
          . . @ > { ? 2 ' % < . .         
           . . . . : ; ; 4 Q / .          

Two .s takes 1 bit. Any other characters take 1 bit and a base-97 digit.

Explanation

Click at the images for larger size. Each explanation part has corresponding Python code to help understanding.

Data part

Instead of the complex structure used in some other answers (with <, " and some other things), I just let the IP pass through the lower half.

Data

First, the IP runs through a lot of numbers and no-op's (.) and mirrors (\). Each digit appends to the number in the memory, so in the end the memory value is equal to the number at the start of the program.

mem = 362003511...99306179

! prints it,

stdout.write(str(mem))

and $ jumps through the next >.

Starting from the <. If the memory value mem is falsy (<= 0, i.e., the condition mem > 0 is not satisfied), we have done printing the program, and should exit. The IP would follow the upper path.

Exit

(let the IP runs around the world for about 33 commands before hitting the @ (which terminates the program) because putting it anywhere else incurs some additional bytes)

If it's true, we follow the lower path, get redirected a few times and execute some more commands before hitting another conditional.

# Python                    # Hexagony
# go to memory cell (a)     # {
a = 2                       # ?2
# go to memory cell (b)     # '
b = mem % a                 # %

Now the memory looks like this:

Mem1

If the value is truthy:

if b > 0:

the following code is executed:

# Python                    # Hexagony
b = ord('Q')                # Q
b = b*10+4                  # 4
# Note: now b == ord('.')+256*3
stdout.write(chr(b%256))    # ;
stdout.write(chr(b%256))    # ;

See detailed explanation of the Q4 at MartinEnder's HelloWorld Hexagony answer. In short, this code prints . twice.

Originally I planned for this to print . once. When I came up with this (print . twice) and implement it, about 10 digits were saved.

Then,

b = mem // a                # :

Here is a important fact I realized that saved me about 14 digits: You don't need to be at where you started.


To understand what I'm saying, let's have a BF analogy. (skip this if you already understood)

Given the code

while a != 0:
    b, a = a * 2, 0
    a, b = b, 0
    print(a)

Assuming we let a be the value of the current cell and b be the value of the right cell, a straightforward translation of this to BF is:

[             # while a != 0:
    [->++<]       # b, a = a * 2, 0
    >[-<+>]       # a, b = b, 0
    <.            # print(a)
]

However, note that we don't need to be at the same position all the time during the program. We can let the value of a be whatever we are at the start of each iteration, then we have this code:

[             # while a != 0:
    [->++<]       # b, a = a * 2, 0
                  # implicitly let (a) be at the position of (b) now
    .             # print(a)
]

which is several bytes shorter.


Also, the corner wrapping behavior also saves me from having a \ mirror there - without it I would not be able to fit the digits (+2 digits for the \ itself and +2 digits for an unpaired . to the right of it, not to mention the flags)

(details:

  • The IP enters the lower-left corner, heading left
  • It get warped to the right corner, still heads left
  • It encounters a \ which reflects it, now it heads right-up
  • It goes into the corner and get warped again to the lower-left corner

)


If the value (of the mod 2 operation above) is falsy (zero), then we follow this path:

# Python                 # Hexagony   # Memory visualization after execution
b = mem // a             # :          # click here
base = ord('a') # 97     # a
y = b % base             # '%
offset = 33              # P1
z = y + offset           # ='+
stdout.write(chr(z))     # ;          # click here
mem = b // base          # {:         # click here

I won't explain too detailed here, but the offset is actually not exactly 33, but is congruent to 33 mod 256. And chr has an implicit % 256.

user202729

Posted 2011-01-28T00:34:05.293

Reputation: 14 620

3Man, that is a lot of no-ops – Jo King – 2018-02-21T08:02:23.510

26I laughed at "To understand what I'm saying, let's have a [BrainFuck] analogy." Only on PPCG... :) – Lynn – 2018-02-23T16:52:20.120

2I scrolled like 3 times to the top of the answer to upvote it, only to find out that I did it already... – NieDzejkob – 2018-02-23T16:56:30.460

1Just had another look at this: have you tried avoiding { so you can lower the base from a down to A (naively by doing ='= but some restructuring might be able to save on some = there)? That could shorten the data part significantly. – Martin Ender – 2019-09-17T08:44:40.793

@MartinEnder Failed? :( (originally the number is 132 digits long, when base is changed to A and the code is unchanged it's 124 bytes long, but each extra character or unpaired . adds 2 digits, so the added amount must be < 4 bytes to be useful)

– user202729 – 2019-09-19T08:17:14.020

@user202729 Can't you move the code on the last line one cell right to avoid two unpaired .? – Martin Ender – 2019-09-19T08:28:10.790

@MartinEnder I overlooked that. / On another note, combining that idea with changing the offset to 1 gives this, which saves 7 digits in the data part.

– user202729 – 2019-09-19T08:37:03.373

Decoder in side length 10 hexagon. Unfortunately the data is 9 digits longer than the maximum possible. – user202729 – 2019-09-19T08:53:10.260

Are you sure the bottom branch of that decoder works? – Martin Ender – 2019-09-19T08:58:50.990

@MartinEnder not really, but fixing it will make the data longer, not shorter... – user202729 – 2019-09-19T09:02:41.197

@MartinEnder I saved 10 bytes with the no-{ idea anyway. – user202729 – 2019-09-19T09:08:46.627

2310 bytes by taking advantage of the new space from shortening the number – Jo King – 2019-09-19T11:22:04.467

3308 bytes by taking out even more space – Jo King – 2019-09-19T12:38:48.320

46

Vim, 11 bytes

q"iq"qP<Esc>hqP
  • iq"qP<Esc>: Manually insert a duplicate of the text that has to be outside the recording.
  • q" and hqP: Record the inside directly into the unnamed "" register, so it can be pasted in the middle. The h is the only repositioning required; if you put it inside the macro, it will be pasted into the result.

Edit

A note about recording with q": The unnamed register "" is a funny thing. It's not really a true register like the others, since text isn't stored there. It's actually a pointer to some other register (usually "- for deletes with no newline, "0 for yanks, or "1 for deletes with a newline). q" breaks the rules; it actually writes to "0. If your "" was already pointing to some register other than "0, q" will overwrite "0 but leave "" unchanged. When you start a fresh Vim, "" automatically points to "0, so you're fine in that case.

Basically, Vim is weird and buggy.

udioica

Posted 2011-01-28T00:34:05.293

Reputation: 2 381

wait why doesn't this work for me – Destructible Lemon – 2016-10-14T07:32:22.580

@DestructibleWatermelon Can't say for sure, but one explanation is most likely. Probably should have had it in the write-up before, since it can throw people off. Read the edit. – udioica – 2016-10-14T08:19:39.377

you should probably put something about how pressing y or something before running can help – Destructible Lemon – 2016-10-14T08:25:26.633

Why don't you use to show pressing the <Esc> key? Part of this Unicode Block “Control Pictures”

– mbomb007 – 2016-10-15T20:25:51.817

5@mbomb007 The <Esc> notation is standard in Vim mappings (:help <>) and that's what vimgolf.com uses. Any experienced vimgolfer will be used to reading it. As for the unicode, I have to squint to read the little letters, and they obscure the method of typing them and searching the help file. – udioica – 2016-10-15T21:44:42.800

Can you explain more? – CalculatorFeline – 2016-10-16T22:19:18.680

45

Cubix, 20 bytes

3434Qu$v@!<"OOw\o;/"

Almost got the \o/...

Net:

    3 4
    3 4
Q u $ v @ ! < "
O O w \ o ; / "
    . .
    . .

Try it online

Try it here!

Additional notes

Background story

After being impressed by reading this great answer by @ais523, I started thinking about further golfing the quine. After all, there were quite a few no-ops in there, and that didn't feel very compressed. However, as the technique his answer (and mine as well) uses, requires the code to span full lines, a saving of at least 12 bytes was needed. There was one remark in his explanation that really got me thinking:

On the subject of golfing down this quine further, [...] it'd need [...] some other way to represent the top face of the cube [...]

Then, suddenly, as I stood up and walked away to get something to drink, it struck me: What if the program didn't use character codes, but rather numbers to represent the top face? This is especially short if the number we're printing has 2 digits. Cubix has 3 one-byte instructions for pushing double-digit numbers: N, S and Q, which push 10, 32 and 34 respectively, so this should be pretty golfy, I thought.

The first complication with this idea is that the top face is now filled with useless numbers, so we can't use that anymore. The second complication is that the top face has a size which is the cube size squared, and it needed to have an even size, otherwise one number would also end up on the starting position of the instruction pointer, leading to a polluted stack. Because of these complications, my code needed to fit on a cube of size 2 (which can contain 'only' 24 bytes, so I had to golf off at least 21 bytes). Also, because the top and bottom faces are unusable, I only had 16 effective bytes.

So I started by choosing the number that would become half of the top face. I started out with N (10), but that didn't quite work out because of the approach I was taking to print everything. Either way, I started anew and used S (32) for some reason. That did result in a proper quine, or so I thought. It all worked very well, but the quotes were missing. Then, it occured to me that the Q (34) would be really useful. After all, 34 is the character code of the double quote, which enables us to keep it on the stack, saving (2, in the layout I used then) precious bytes. After I changed the IP route a bit, all that was left was an excercise to fill in the blanks.

How it works

The code can be split up into 5 parts. I'll go over them one by one. Note that we are encoding the middle faces in reverse order because the stack model is first-in-last-out.

Step 1: Printing the top face

The irrelevant instructions have been replaced by no-ops (.). The IP starts the the third line, on the very left, pointing east. The stack is (obviously) empty.

    . .
    . .
Q u . . . . . .
O O . . . . . .
    . .
    . .

The IP ends at the leftmost position on the fourth line, pointing west, about to wrap around to the rightmost position on that same line. The instructions executed are (without the control flow character):

QOO
Q   # Push 34 (double quotes) to the stack
 OO # Output twice as number (the top face)

The stack contains just 34, representlng the last character of the source.

Step 2: Encode the fourth line

This bit pretty much does what you expect it to do: encode the fourth line. The IP starts on the double quote at the end of that line, and goes west while pushing the character codes of every character it lands on until it finds a matching double quote. This matching double quote is also the last character on the fourth line, because the IP wraps again when it reaches the left edge.

Effectively, the IP has moved one position to the left, and the stack now contains the representation of the fourth line in character codes and reverse order.

Step 3: Push another quote

We need to push another quote, and what better way than to recycle the Q at the start of the program by approaching it from the right? This has the added bonus that the IP directly runs into the quote that encodes the third line.

Here's the net version for this step. Irrelevant intructions have been replaced by no-ops again, the no-ops that are executed have been replaced by hashtags (#) for illustration purposes and the IP starts at the last character on the fourth line.

    . .
    . .
Q u $ . . . . .
. . w \ . . / .
    . #
    . #

The IP ends on the third line at the first instruction, about to wrap to the end of that line because it's pointing west. The following instructions (excluding control flow) are excecuted:

$uQ
$u  # Don't do anthing
  Q # Push the double quote

This double quote represents the one at the end of the third line.

Step 4: Encoding the third line

This works exactly the same as step 2, so please look there for an explanation.

Step 5: Print the stack

The stack now contains the fourth and third lines, in reverse order, so all we need to do now, it print it. The IP starts at the penultimate instruction on the third line, moving west. Here's the relevant part of the cube (again, irrelevant parts have been replaced by no-ops).

    . .
    . .
. . . v @ ! < .
. . . \ o ; / .
    . .
    . .

This is a loop, as you might have seen/expected. The main body is:

o;
o  # Print top of stack as character
 ; # Delete top of stack

The loop ends if the top item is 0, which only happens when the stack is empty. If the loop ends, the @ is executed, ending the program.

Luke

Posted 2011-01-28T00:34:05.293

Reputation: 4 675

wish I could upvote this more – MickyT – 2017-04-27T02:00:14.597

Bounties are always welcome ;-) – Luke – 2017-04-27T07:23:34.737

43

Javascript ES6 - 21 bytes

$=_=>`$=${$};$()`;$()

I call this quine "The Bling Quine."

Sometimes, you gotta golf in style.

Mama Fun Roll

Posted 2011-01-28T00:34:05.293

Reputation: 7 234

Does !$=_=>\!$=${$}()`()` save you 2 bytes? – Downgoat – 2016-02-17T06:20:52.313

Invalid assignment left hand side. Wish it worked :( – Mama Fun Roll – 2016-02-17T14:21:11.043

Does !_=>\!$=${$}()`()` work ? – Downgoat – 2016-02-17T16:36:33.167

Declaration of quine is missing. Nope. – Mama Fun Roll – 2016-02-18T01:15:27.887

$=_=>eval(`$=${$};$()`);$() is a rather amusing quine to crash your browser. – Patrick Roberts – 2016-07-29T15:27:24.170

@PatrickRoberts $=_=>eval\$=${$};$()`;$()` Two bytes off – TuxCrafting – 2016-10-20T21:38:34.050

@TùxCräftîñg that won't work – Patrick Roberts – 2016-10-20T21:45:01.557

1@TùxCräftîñg eliminating parentheses around template literals only works on native prototype functions, like Array.prototype.join. – Mama Fun Roll – 2016-10-21T03:44:31.707

@MamaFunRoll TIL – TuxCrafting – 2016-10-21T10:35:40.647

I love this one so much. I don't think it's quite correct, though - the REPL environments I run it in all enclose the output in quotes, and evaluating it with node.js doesn't output anything. Needs a console.log somewhere. – TehShrike – 2017-01-12T21:16:15.030

2Hmm, not sure. I wrote this over a year ago (it was considered valid then), and I haven't been following quine rule changes too closely. However, adding alert or console.log after the arrow function and wrapping the template string in parentheses would work. – Mama Fun Roll – 2017-01-12T22:12:17.230

3Also if You run this in the concole, it overwrites $ ( jQuery function ) on this site, and the upvote function won't work anymore. :) – Steven Palinkas – 2017-05-19T11:09:28.193

If this is a quine, 0 is too. – frederick99 – 2019-05-26T05:41:16.673

41

Brainf*ck (755 characters)

This is based off of a technique developed by Erik Bosman (ejbosman at cs.vu.nl). Note that the "ESultanik's Quine!" text is actually necessary for it to be a quine!

->++>+++>+>+>++>>+>+>+++>>+>+>++>+++>+++>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+>++>>>+++>>>>>+++>+>>>>>>>>>>>>>>>>>>>>>>+++>>>>>>>++>+++>+++>+>>+++>>>+++>+>+++>+>++>+++>>>+>+>+>+>++>+++>+>+>>+++>>>>>>>+>+>>>+>+>++>+++>+++>+>>+++>+++>+>+++>+>++>+++>++>>+>+>++>+++>+>+>>+++>>>+++>+>>>++>+++>+++>+>>+++>>>+++>+>+++>+>>+++>>+++>>>+++++++++++++++>+++++++++++++>++++++>+++++++++++++++>++++++++++>+++>+++>++++>++++++++++++++>+++>++++++++++>++++>++++++>++>+++++>+++++++++++++++>++++++++>++++>++++++++++++>+++++++++++++++>>++++>++++++++++++++>+++>+++>++++>++++++>+++>+++++++++>++++>+>++++>++++++++++>++++>++++++++>++>++++++++++>+>+++++++++++++++>+++++++++++++
ESultanik's Quine!
+[[>>+[>]+>+[<]<-]>>[>]<+<+++[<]<<+]>>+[>]+++[++++++++++>++[-<++++++++++++++++>]<.<-<]

ESultanik

Posted 2011-01-28T00:34:05.293

Reputation: 1 078

3@proudhaskeller IIRC, the part before ESultanik's Quine! sets up the memory as a stack encoding ESultanik's Quine! and onward, with two bytes of memory for each character (ASCII value offsets from 0x1F). The final bit of code loops through the memory, first programmatically reproducing the ++>+++… codes for each character, then actually printing the characters. – ESultanik – 2016-02-09T15:48:20.197

Can be golfed by removing unnecessary chars like newlines, 'E"s, and other insignificant characters. – CalculatorFeline – 2016-03-07T05:31:41.537

4@CatsAreFluffy They are required for it to be a quine! While it is true that they could be removed, one would also have to change the preceding code to maintain the quine property. – ESultanik – 2016-03-07T12:05:50.087

1That's true. Also the newlines are necessary. – CalculatorFeline – 2016-03-07T16:39:04.973

To make this even better, Mr. Bosman created a brainf*ck quine that is 410 characters long and some Mr. Christofani modified it, so it uses only 392 characters. This is how it looks like: ->++>+++>+>+>+++>>>>>>>>>>>>>>>>>>>>+>+>++>+++>++>>+++>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+>>+++>>+++>>>>>+++>+>>>>>>>>>++>+++>+++>+>>+++>>>+++>+>++>+++>>>+>+>++>+++>+>+>>+++>>>>>>>+>+>>>+>+>++>+++>+++>+>>+++>>>+++>+>++>+++>++>>+>+>++>+++>+>+>>+++>>>>>+++>+>>>>>++>+++>+++>+>>+++>>>+++>+>+++>+>>+++>>+++>>++[[>>+[>]++>++[<]<-]>+[>]<+<+++[<]<+]>+[>]++++>++[[<++++++++++++++++>-]<+++++++++.<] – Dorian – 2018-06-19T09:58:01.470

13That's a clever way to do it. – Peter Olson – 2011-06-22T16:48:11.263

13How does it work? – proud haskeller – 2014-09-13T16:21:34.933

36

Hexagony, side length 15 14 13 12, 616 533 456 383 bytes

After several days of careful golfing, rearranging loops and starting over, I've finally managed to get it down to a side 12 hexagon.

1845711724004994017660745324800783542810548755533855003470320302321248615173041097895645488030498537186418612923408209003405383437728326777573965676397524751468186829816614632962096935858"">./<$;-<.....>,.........==.........<"......."">'....>+'\.>.........==........<"......"">:>)<$=<..>..............$..<"...."">\'Q4;="/@>...............<"....."">P='%<.>.............<"..!'<.\=6,'/>

Try it online!

Unfolded:

            1 8 4 5 7 1 1 7 2 4 0 0
           4 9 9 4 0 1 7 6 6 0 7 4 5
          3 2 4 8 0 0 7 8 3 5 4 2 8 1
         0 5 4 8 7 5 5 5 3 3 8 5 5 0 0
        3 4 7 0 3 2 0 3 0 2 3 2 1 2 4 8
       6 1 5 1 7 3 0 4 1 0 9 7 8 9 5 6 4
      5 4 8 8 0 3 0 4 9 8 5 3 7 1 8 6 4 1
     8 6 1 2 9 2 3 4 0 8 2 0 9 0 0 3 4 0 5
    3 8 3 4 3 7 7 2 8 3 2 6 7 7 7 5 7 3 9 6
   5 6 7 6 3 9 7 5 2 4 7 5 1 4 6 8 1 8 6 8 2
  9 8 1 6 6 1 4 6 3 2 9 6 2 0 9 6 9 3 5 8 5 8
 " " > . / < $ ; - < . . . . . > , . . . . . .
  . . . = = . . . . . . . . . < " . . . . . .
   . " " > ' . . . . > + ' \ . > . . . . . .
    . . . = = . . . . . . . . < " . . . . .
     . " " > : > ) < $ = < . . > . . . . .
      . . . . . . . . . $ . . < " . . . .
       " " > \ ' Q 4 ; = " / @ > . . . .
        . . . . . . . . . . . < " . . .
         . . " " > P = ' % < . > . . .
          . . . . . . . . . . < " . .
           ! ' < . \ = 6 , ' / > . .
            . . . . . . . . . . . .

While it doesn't look like the most golfed of Hexagony code, the type of encoding I used is optimised for longer runs of no-ops, which is something you would otherwise avoid.

Explanation

This beats the previous Hexagony answer by encoding the no-ops (.) in a different way. While that answer saves space by making every other character a ., mine encodes the number of no-ops. It also means the source doesn't have to be so restricted.

Here I use a base 80 encoding, where numbers below 16 indicate runs of no-ops, and numbers between 16 and 79 represent the range 32 (!) to 95 (_) (I'm just now realising I golfed all the _s out of my code lol). Some Pythonic pseudocode:

i = absurdly long number
print(i)
base = 80
n = i%base
while n:
    if n < 16:
        print("."*(16-n))
    else:
        print(ASCII(n+16))
    i = i//base
    n = i%base

The number is encoded in the first half of the hexagon, with all the

" " > 
 " " > 
  ... etc

on the left side and the

 > ,
< "
 >
< "
... etc

on the right side redirecting the pointer to encode the number into one cell. This is taken from Martin Ender's answer (thanks), because I couldn't figure out a more efficient way.

It then enters the bottom section through the ->:

       " " > \ ' Q 4 ; = " / @ > . . . .
        . . . . . . . . . . . < " . . .
         . . " " > P = ' % < . > . . .
          . . . . . . . . . . < " . .
     ->    ! ' < . \ = 6 , ' / > . .

! prints the number and ' navigates to the right memory cell before starting the loop. P='% mods the current number by 80. If the result is 0, go up to the terminating @, else go down and create a cell next to the mod result with the value -16.

   . " " > ' . . . . > + ' \ . > . . . . . .
    . . . = = . . . . . . . . < " . . . . .
     . " " > : > ) < $ = < . . > . . . . .
      . . . . . . . . . $ . . < " . . . .
       " " > \ ' Q 4 ; = " / @ > . . . .
                      /
                     /

Set the cell to (mod value + -16). If that value is negative, go up at the branching >+'\, otherwise go down.

If the value is positive:

 " " > . / < $ ; - < . . . . . > , . . . . . .
  . . . = = . . . . . . . . . < " . . . . . .
   . " " > ' . . . . > + ' \ . > . . . . . .

The pointer ends up at the ;-< which sets the cell to (mod value - -16) and print it.

The the value is negative:

   . " " > ' . . . . > + ' \ . > . . . . . .
    . . . = = . . . . . . . . < " . . . . .
     . " " > : > ) < $ = < . . > . . . . .

Go down to the > ) < section which starts the loop. Here it is isolated:

     . . > ) < $ = < . .
      . . . . . . . . .
       \ ' Q 4 ; = " /

Which executes the code 'Q4;="= which prints a . (thanks again to Martin Ender, who wrote a program to find the letter-number combinations for characters) and moves back to the starting cell. It then increments ()) the mod value cell and loops again, until the mod value is positive.

When that is done, it moves up and joins with the other section at:

 " " > . / < $ ; - < . . .
            \
             \

The pointer then travels back to the start of the larger loop again

 " " > . / <--
  . . . = =
   . " " > ' 
    . . . = = 
     . " " > :
      . . . . .
       " " > \ ' . .
        . . . . . . .
         . . " " > P = ' % < . > . . .

This executes ='=:' which divides the current number by 80 and navigates to the correct cell.

Old version (Side length 13)

343492224739614249922260393321622160373961419962223434213460086222642247615159528192623434203460066247203920342162343419346017616112622045226041621962343418346002622192616220391962343417346001406218603959366061583947623434"">/':=<$;'<.....>(......................<"......"">....'...>=\..>.....................<"....."">....>)<.-...>...........==......<"...."">.."...'.../>.................<"..."">\Q4;3=/.@.>...............<".."".>c)='%<..>..!'<.\1*='/.\""

Try it online!

I can most definitely golf another side length off this, but I'll have to leave it til' tomorrow because it's getting late. Turns out I'm impatient and can't wait until tomorrow. Maybe another side can be golfed? :( ahhhhhhhhh i did it!

I even golfed off a couple of extra digits with a base 77 encoding, but it doesn't really matter, since it has the same bytecount.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

13This is amazing. The idea for this hybrid run-length encoding is really neat. :) Remind me to give you a bounty if I forget. – Martin Ender – 2018-02-10T12:03:43.930

35

PostScript, 20 chars

Short and legit. 20 chars including trailing newline.

(dup == =)
dup == =

KirarinSnow

Posted 2011-01-28T00:34:05.293

Reputation: 801

34

Python 2, 30 bytes

_='_=%r;print _%%_';print _%_


Taken from here

hallvabo

Posted 2011-01-28T00:34:05.293

Reputation: 1 640

2It looks weird with the variable name as _, but reads better if you assign it to any letter, i.e. s: s='s=%r;print s%%s';print s%s – Ehtesh Choudhury – 2015-10-14T16:20:08.627

5If this solution is not your own creation, you should make it Community Wiki. Also, the link is dead. – mbomb007 – 2016-04-27T20:12:03.443

1I'm a bit late to the party, but can someone explain how this works? – MadTux – 2016-10-12T15:31:43.747

1@MadTux % is the string formatting operator; in this case, x % y replaces all instances of %r in x with y formatted as a string. The % must be escaped with a second %. – Conor O'Brien – 2016-10-17T17:53:49.403

9This requires a trailing linefeed to be valid. As it is, the source code doesn't match the output. – Dennis – 2017-01-05T17:10:48.243

1+1, you beat my similar solution so I deleted it. It should be noted that this only works in Python 2. – nyuszika7h – 2014-04-28T12:32:32.700

33

Cubix, 45 bytes

.....>...R$R....W..^".<R.!'.\)!'"R@>>o;?/o'u"

You can test this code here.

This program is fairly hard to follow, but to have any chance to do so, we need to start by expanding it into a cube, like the Cubix interpreter does:

      . . .
      . . >
      . . .
R $ R . . . . W . . ^ "
. < R . ! ' . \ ) ! ' "
R @ > > o ; ? / o ' u "
      . . .
      . . .
      . . .

This is a Befunge-style quine, which works via exploiting wrapping to make string literals "wrap around" executable code (with only one " mark, the code is both inside and outside the quote at the same time, something that becomes possible when you have programs that are nonlinear and nonplanar). Note that this fits our definition of a proper quine, because two of the double quotes don't encode themselves, but rather are calculated later via use of arithmetic.

Unlike Befunge, though, we're using four strings here, rather than one. Here's how they get pushed onto the stack;

  1. The program starts at the top of the left edge, going rightwards; it turns right twice (R), making it go leftwards along the third and last of the lines that wrap around the whole cube. The double quote matches itself, so we push the entire third line onto the stack backwards. Then execution continues after the double quote.

  2. The u command does a U-turn to the right, so the next thing we're running is from '" onwards on the middle line. That pushes a " onto the stack. Continuing to wrap around, we hit the < near the left hand side of the cube and bounce back. When approaching from this direction, we see a plain " command, not '", so the entire second line is pushed onto the stack backwards above the third line and the double quote.

  3. We start by pushing a ! onto the stack ('!) and incrementing it ()); this produces a double quote without needing a double quote in our source code (which would terminate the string). A mirror (\) reflects the execution direction up northwards; then the W command sidesteps to the left. This leaves us going upwards on the seventh column, which because this is a cube, wraps to leftwards on the third row, then downwards on the third column. We hit an R, to turn right and go leftwards along the top row; then the $ skips the R via which we entered the program, so execution wraps round to the " at the end of the line, and we capture the first line in a string the same way that we did for the second and third.

  4. The ^ command sends us northwards up the eleventh column, which is (allowing for cube wrapping) southwards on the fifth. The only thing we encounter there is ! (skip if nonzero; the top of the stack is indeed nonzero), which skips over the o command, effectively making the fifth column entirely empty. So we wrap back to the u command, which once again U-turns, but this time we're left on the final column southwards, which wraps to the fourth column northwards. We hit a double quote during the U-turn, though, so we capture the entire fourth column in a string, from bottom to top. Unlike most double quotes in the program, this one doesn't close itself; rather, it's closed by the " in the top-right corner, meaning that we capture the nine-character string ...>......

So the stack layout is now, from top to bottom: fourth column; top row; "; middle row; "; bottom row. Each of these are represented on the stack with the first character nearest the top of the stack (Cubix pushes strings in the reverse of this order, like Befunge does, but each time the IP was moving in the opposite direction to the natural reading direction, so it effectively got reversed twice). It can be noted that the stack contents are almost identical to the original program (because the fourth column, and the north/top face of the cube, contain the same characters in the same order; obviously, it was designed like that intentionally).

The next step is to print the contents of the stack. After all the pushes, the IP is going northwards on the fourth column, so it hits the > there and enters a tight loop >>o;? (i.e. "turn east, turn east, output as character, pop, turn right if positive"). Because the seventh line is full of NOPs, the ? is going to wrap back to the first >, so this effectively pushes the entire contents of the stack (? is a no-op on an empty stack). We almost printed the entire program! Unfortunately, it's not quite done yet; we're missing the double-quote at the end.

Once the loop ends, we reflect onto the central line, moving west, via a pair of mirrors. (We used the "other side" of the \ mirror earlier; now we're using the southwest side. The / mirror hasn't been used before.) We encounter '!, so we push an exclamation mark (i.e. 33; we're using ASCII and Cubix doesn't distinguish between integers and characters) onto the stack. (Conveniently, this is the same ! which was used to skip over the o command earlier.) We encounter a pair of R commands and use them to make a "manual" U-turn (the second R command here was used earlier in order to reach the first row, so it seemed most natural to fit another R command alongside it.) The execution continues along a series of NOPs until it reaches the W command, to sidestep to the left. The sidestep crashes right into the > command on the second line, bouncing execution back exactly where it was. So we sidestep to the left again, but this time we're going southwards, so the next command to execute is the ) (incrementing the exclamation mark into a double quote), followed by an o (to output it). Finally, execution wraps along the eighth line to the second column, where it finds a @ to exit the program.

I apologise for the stray apostrophe on the third line. It doesn't do anything in this version of the program; it was part of an earlier idea I had but which turned out not to be necessary. However, once I'd got a working quine, I just wanted to submit it rather than mess around with it further, especially as removing it wouldn't change the byte count. On the subject of golfing down this quine further, it wouldn't surprise me if this were possible at 3×3 by only using the first five lines, but I can't see an obvious way to do that, and it'd need even tighter packing of all the control flow together with some other way to represent the top face of the cube (or else modifying the algorithm so that it can continue to use the fourth column even though it'd now be ten or eleven characters long).

user62131

Posted 2011-01-28T00:34:05.293

Reputation:

Nice work, this is a really impressive score. I love how you encoded the top face. :) – Martin Ender – 2016-12-18T08:45:46.120

This is just incredible! If it would help any, another way to push " is Q. – ETHproductions – 2016-12-18T12:24:41.173

1Wow! I never though I'd see a cubix quine! – FlipTack – 2016-12-19T15:28:45.607

3I didn't have time to read the explanation yesterday, but now that I have... Just... WOW. I can't believe how many characters are used for two or even three completely different purposes. This is probably the coolest Cubix program I've ever seen. – ETHproductions – 2016-12-19T16:47:05.070

Good explanation. – Robert Fraser – 2017-03-22T03:28:37.743

32

Vim, 17, 14 keystrokes

Someone randomly upvoted this, so I remembered that it exists. When I re-read it, I thought "Hey, I can do better than that!", so I golfed two bytes off. It's still not the shortest, but at least it's an improvement.


For a long time, I've been wondering if a vim quine is possible. On one hand, it must be possible, since vim is turing complete. But after looking for a vim quine for a really long time, I was unable to find one. I did find this PPCG challenge, but it's closed and not exactly about literal quines. So I decided to make one, since I couldn't find one.

I'm really proud of this answer, because of two firsts:

  1. This is the first quine I have ever made, and

  2. As far as I know, this is the worlds first vim-quine to ever be published! I could be wrong about this, so if you know of one, please let me know.

So, after that long introduction, here it is:

qqX"qpAq@q<esc>q@q

Try it online!

Note that when you type this out, it will display the <esc> keystroke as ^[. This is still accurate, since ^[ represents 0x1B, which is escape in ASCII, and the way vim internally represents the <esc> key.

Also note, that testing this might fail if you load an existing vim session. I wrote a answer explaining that here, if you want more information, but basically you need to launch vim with

vim -u NONE -N -i NONE

or type qqq before running this.

Explanation:

qq                  " Start recording into register 'q'
  X                 " Delete one character before the cursor (Once we play this back, it will delete the '@')
   "qp              " Paste register 'q'
      Aq@q<esc>     " Append 'q@q' to this line
               q    " Stop recording
                @q  " Playback register 'q'

On a side note, this answer is probably a world record for most 'q's in a PPCG answer, or something.

James

Posted 2011-01-28T00:34:05.293

Reputation: 54 537

12i2i<esc> is so close. I feel like there must be something I can do to make this work. – Zwei – 2016-10-01T20:41:08.353

@zwei I know, it's close it hurts! Actually, <Esc> is implicit in V, so that works. Unfortunately it also adds a newline, which is why I haven't posted it yet.

– James – 2016-10-01T20:43:37.787

q"iq"qbP<Esc>qbP is 11. After you put this on reddit, I investigated the vimgolfing here and decided to make an account. This is the answer I posted there. – udioica – 2016-10-11T12:49:19.107

2@udioica Can you post that as an answer? – James – 2016-10-11T12:59:19.230

29

Lost, 120 116 98 96 76 70 66 bytes

Edit: yay, under 100

Edit: Saved a bunch o' bytes by switching to all /s on the bottom line

:2+52*95*2+>::1?:[:[[[[@^%?>([ "
////////////////////////////////

Try it online! + verification it's deterministic for all possible states

Lost is a 2D language in which the starting position and direction are completely random. This means there has to be a lot of error-checking at every stage to make sure you've got the correct instruction pointer, and it isn't one that has just wandered in randomly.

Explanation:

All the /s on the bottom line are there to make sure that all the pointers that spawn in a vertical direction or on the bottom line get funneled in the right direction. From there, they end up at several different places, but all of them end up going right into the

 ^%?>
 ////

Which clears out all the non-zero numbers in the stack. The ([ after that clears out any extra 0s as well.

In the middle of the clear, it hits the %, which turns the 'safety' off, which allows the program to end when it hits the @ (without this, the program could end immediately if a pointer started at the @).

From there it does a pretty simple 2D language quine, by wrapping a string literal (") around the first line, pushing a " character by duping a space (:2+) and then a newline (52*). For the second line, it creates a / character (95*2+) and duplicates it a bunch (>::1?:[:[[[[), before finally ending at the @ and printing the stack implicitly. The ?1 is to stop the process from creating too many 0s if the pointer enters early, saving on having to clear them later.

I saved 20 bytes here by making the last line all the same character, meaning I could go straight from the duping process into the ending @.

Explanation about the duping process:

[ is a character known as a 'Door'. If the pointer hits the flat side of a [ or a ] , it reflects, else it passes through it. Each time the pointer interacts with a Door, it switches to the opposite type. Using this knowledge we can construct a simple formula for how many times an instruction will execute in a >:[ block.

Add the initial amount of instructions. For each [, add 2 times the amount of instructions to the left of it. For the example >::::[:[[[, we start with 5 as the initial amount. The first Door has 4 dupe instructions, so we add 4*2=8 to 5 to get 13. The other three Doors have 5 dupes to their left, so we add 3*(5*2)=30 to 13 to get 43 dupe instructions executed, and have 44 >s on the stack. The same process can be applied to other instructions, such as ( to push a large amount of items from the stack to the scope, or as used here, to clear items from the stack.

A trick I've used here to avoid duping too many 0s is the 1?. If the character is 0, the ? doesn't skip the 1, which means it duplicates 1 for the remainder of the dupe. This makes it much easier to clear the stack later on.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

26

C, 64 60 bytes

main(s){printf(s="main(s){printf(s=%c%s%1$c,34,s);}",34,s);}

So far, this is the shortest known C quine. There's an extended bounty if you find a shorter one.

This works in GCC, Clang, and TCC in a POSIX environment. It invokes an excessive amount of undefined behavior with all of them.

Just for fun, here's a repo that contains all the C quines I know of. Feel free to fork/PR if you find or write a different one that adds something new and creative over the existing ones.

Note that it only works in an ASCII environment. This works for EBCDIC, but still requires POSIX. Good luck finding a POSIX/EBCDIC environment anyway :P


How it works:

  1. main(s) abuses main's arguments, declaring a virtually untyped variable s. (Note that s is not actually untyped, but since listed compilers auto-cast it as necessary, it might as well be*.)
  2. printf(s="..." sets s to the provided string and passes the first argument to printf.
  3. s is set to main(s){printf(s=%c%s%1$c,34,s);}.
  4. The %c is set to ASCII 34, ". This makes the quine possible. Now s looks like this:
    main(s){printf(s="%s%1$c,34,s);}.
  5. The %s is set to s itself, which is possible due to #2. Now s looks like this:
    main(s){printf(s="main(s){printf(s=%c%s%1$c,34,s);}%1$c,34,s);}.
  6. The %1$c is set to ASCII 34 ", printf's first** argument. Now s looks like this:
    main(s){printf(s="main(s){printf(s=%c%s%1$c,34,s);}",34,s);}
    ... which just so happens to be the original source code.

* Example thanks to @Pavel
** first argument after the format specifier - in this case, s. It's impossible to reference the format specifier.


I think it's impossible that this will get any shorter with the same approach. If printf's format specifier was accessible via $, this would work for 52 bytes:

main(){printf("main(){printf(%c%0$s%1$c,34);}",34);}

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

Although it certainly shouldn't count as competing, the winner of "Worst abuse of the rules" from the 1994 International Obfuscated C Code Contest, 1994_smr.c, is definitely shorter.

– Ray – 2017-05-31T19:59:58.570

1@Ray It's not allowed. It's not a proper quine by any definition. The quien rules were changed because of that program :P – MD XF – 2017-05-31T20:00:49.213

I agree entirely, but it's an interesting enough hack that it's worth mentioning any time someone mentions a smallest known quine, if only for historical reasons. – Ray – 2017-05-31T20:10:45.820

@Ray Well... smallest known valid quine, anyway. – MD XF – 2017-05-31T20:11:38.947

4s is of type int, not an "untyped variable". – feersum – 2017-07-22T05:32:58.903

2These compilers all apparently allow implicit conversion of a pointer to an int. s=3 obviously wouldn't work because you need to pass the string twice to printf. – feersum – 2017-07-22T19:09:20.540

@jxh I added everything from the nyx.net list, and I'll add Adam's. Thanks! – MD XF – 2017-12-07T00:34:42.097

@jxh I wouldn't consider an EBCDIC-only solution worthy of the bounty for beating this quine, but I'd add one to the repo with a note. – MD XF – 2017-12-07T01:58:46.380

@jxh Well, this quine (the 60-byter) is ASCII/EBCDIC-independent, so I think it's safe. For the repo, I'll clarify that. – MD XF – 2017-12-07T02:04:53.480

@jxh Additionally, I've clarified the bounty.

– MD XF – 2017-12-07T02:07:56.223

@jxh Oh, I do use ASCII codes! I completely forgot... sorry about that. I've edited the answer. – MD XF – 2017-12-07T02:32:00.530

25

Cross-browser JavaScript (41 characters)

It works in the top 5 web browsers (IE >= 8, Mozilla Firefox, Google Chrome, Safari, Opera). Enter it into the developer's console in any one of those:

eval(I="'eval(I='+JSON.stringify(I)+')'")

It's not "cheating" — unlike Chris Jester-Young's single-byte quine, as it could easily be modified to use the alert() function (costing 14 characters):

alert(eval(I="'alert(eval(I='+JSON.stringify(I)+'))'"))

Or converted to a bookmarklet (costing 22 characters):

javascript:eval(I="'javascript:eval(I='+JSON.stringify(I)+')'")

PleaseStand

Posted 2011-01-28T00:34:05.293

Reputation: 5 369

25

Fission, 6 bytes

It appears this is now the shortest "proper" quine among these answers.

'!+OR"

Explanation

Control flow starts at R with a single right-going (1,0) atom. It hits " toggling print mode and then wraps around the line, printing '!+OR before hitting the same " again and exiting print mode.

That leaves the " itself to be printed. The shortest way is '"O (where '" sets the atom's mass to the character code of " and O prints the character and destroys the atom), but if we did this the " would interfere with print mode. So instead we set the atom's value to '! (one less than "), then increment with + and then print the result with O.

Alternatives

Here are a couple of alternatives, which are longer, but maybe their techniques inspire someone to find a shorter version using them (or maybe they'll be more useful in certain generalised quines).

8 bytes using Jump

' |R@JO"

Again, the code starts at R. The @ swaps mass and energy to give (0,1). Therefore the J makes the atom jump over the O straight onto the ". Then, as before, all but the " are printed in string mode. Afterwards, the atom hits | to reverse its direction, and then passes through '"O printing ". The space is a bit annoying, but it seems necessary, because otherwise the ' would make the atom treat the | as a character instead of a mirror.

8 bytes using two atoms

"'L;R@JO

This has two atoms, starting left-going from L and right-going from R. The left-going atom gets its value set by '" which is then immediately printed with O (and the atom destroyed). For the right-going atom, we swap mass and energy again, jump over the O to print the rest of the code in print mode. Afterwards its value is set by 'L but that doesn't matter because the atom is then discarded with ;.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

Technically invalid due to lack of code/data separation in the source. – CalculatorFeline – 2017-01-05T02:24:47.600

4@CalculatorFeline '!+ encodes ". – Martin Ender – 2017-01-05T08:51:32.933

I'm not familiar with Fission, but would |R@JO"' work, or would you still need that space after the '? – MildlyMilquetoast – 2017-03-06T01:34:38.927

1@MistahFiggins I think so, but more importantly you'd print the ' first. – Martin Ender – 2017-03-06T07:06:53.053

25

These are the two shortest Ruby quines from SO:

_="_=%p;puts _%%_";puts _%_

and

puts <<2*2,2
puts <<2*2,2
2

Don't ask me how the second works...

Nakilon

Posted 2011-01-28T00:34:05.293

Reputation: 605

9The second one uses heredoc, <<2 starts a string on the next line, and *2 repeats the string – Ming-Tang – 2011-01-28T02:52:04.640

Why do you need the 2? – CalculatorFeline – 2016-03-07T05:27:09.660

1

@CalculatorFeline It's the terminator of the heredoc string (which has to appear on its own line). It doesn't actually have to be a 2 though: https://tio.run/##KypNqvz/v6C0pFjBxsZAy0jHgAuFY8D1/z8A

– Martin Ender – 2018-03-02T08:47:51.877

24

Java, 528 bytes:

A Java solution with an original approach:

import java.math.*;class a{public static void main(String[]a){BigInteger b=new BigInteger("90ygts9hiey66o0uh2kqadro71r14x0ucr5v33k1pe27jqk7mywnd5m54uypfrnt6r8aks1g5e080mua80mgw3bybkp904cxfcf4whcz9ckkecz8kr3huuui5gbr27vpsw9vc0m36tadcg7uxsl8p9hfnphqgksttq1wlolm2c3he9fdd25v0gsqfcx9vl4002dil6a00bh7kqn0301cvq3ghdu7fhwf231r43aes2a6018svioyy0lz1gpm3ma5yrspbh2j85dhwdn5sem4d9nyswvx4wmx25ulwnd3drwatvbn6a4jb000gbh8e2lshp",36);int i=0;for(byte c:b.toByteArray()){if(++i==92)System.out.print(b.toString(36));System.out.print((char)c);}}}

in readable form:

import java.math.*;
class a
{
    public static void main (String [] a)
    {
        BigInteger b=new BigInteger ("90ygts9hiey66o0uh2kqadro71r14x0ucr5v33k1pe27jqk7mywnd5m54uypfrnt6r8aks1g5e080mua80mgw3bybkp904cxfcf4whcz9ckkecz8kr3huuui5gbr27vpsw9vc0m36tadcg7uxsl8p9hfnphqgksttq1wlolm2c3he9fdd25v0gsqfcx9vl4002dil6a00bh7kqn0301cvq3ghdu7fhwf231r43aes2a6018svioyy0lz1gpm3ma5yrspbh2j85dhwdn5sem4d9nyswvx4wmx25ulwnd3drwatvbn6a4jb000gbh8e2lshp", 36); 
        int i=0; 
        for (byte c:b.toByteArray ())
        {
            if (++i==92) 
                System.out.print (b.toString (36)); 
            System.out.print ((char) c);
        }
    }
}

user unknown

Posted 2011-01-28T00:34:05.293

Reputation: 4 210

How does it work? – Loovjo – 2015-05-23T13:02:47.513

1@Loovjo: Similar as other solutions which cut the code in two parts and inserts the whole String which reprensents the code inside again, but the whole code is not just a String but encoded as the long number in base 36 (26 alphabetical characters + 10 digits). – user unknown – 2015-05-24T09:38:57.877

1This could be shortened if you put if(++i==92), – tuskiomi – 2017-06-12T14:00:55.617

2@tuskiomi: Thanks, shortened for two characters – user unknown – 2017-06-12T14:20:01.910

I see one can save another character by (String a*) instead of (String []a), but then I would have to recompute the magic number, so I guess you get the point. :) – user unknown – 2018-01-23T22:32:02.803

1@userunknown Actually, a* as array doesn't exit in Java, that's C. Some other parts to golf: import java.math.*;class a{public static void main(String[]a){BigInteger b=new BigInteger("abc",36);int i=0;for(int c:b.toByteArray())System.out.printf("%s%c",++i==92?b.toString(36):"",c);}}, where abc would be the newly computed magic number String. In java 8+ it's also possible to change class a{public static void main to interface a{static void main, and in Java 10+ it's also possible to change import java.math.*; and BigInteger b=new BigInteger( to var b=new java.math.BigInteger(. – Kevin Cruijssen – 2018-03-23T13:57:45.063

@KevinCruijssen: Yes, it was a... which is even longer, wasn't it? The suggestions: if you like to do it, go for it. With Java9, there is the JShell, which allows to run fragments of code - no classes/interfaces, no main, so thereby bigger savings are possible. – user unknown – 2018-03-23T14:24:28.410

23

Chicken, 7

chicken

No, this is not directly echoed :)

Timtech

Posted 2011-01-28T00:34:05.293

Reputation: 12 038

It's not echoed, it's the string chicken! – Erik the Outgolfer – 2016-06-28T21:45:51.840

No code/data separation, and therefore invalid. – CalculatorFeline – 2017-01-05T02:25:50.243

10@CalculatorFeline Did you read the rules? – Timtech – 2017-01-05T15:36:11.373

By the current quine definition this is not valid, as it should be possible to identify a section of the program which encodes a different part of the program. chicken appears to encode only chicken and nothing else.

– Jo King – 2018-02-20T00:45:34.863

Damnit, you beat me to it :) – Taconut – 2014-02-01T22:42:35.580

1

@JoKing I don't think this is invalid, because the rules of the challenge only prohibit zero-length and cheating (reading your own source file) quines. The only thing that prohibits improper quines is a standard loophole -- except standard loopholes aren't generally considered to apply to answers that predate them.

– pppery – 2019-08-25T01:36:09.230

23

Retina, 20 14 9 7 bytes

Before we get started, I'd like to mention the trivial solution of a file which contains a single 0. In that case Retina will try to count the 0s in the empty input, the result of which is also 0. I wouldn't consider that a proper quine though.

So here is a proper one:

>\`
>\`

Try it online!

Alternatively, we could use ; instead of >.

Explanation

The program consists of a single replacement which we print twice.

In the first line, the ` separates the configuration from the regex, so the regex is empty. Therefore the empty string (i.e. the non-existent input) is replaced with the second line, verbatim.

To print the result twice, we wrap it in two output stages. The inner one, \ prints the result with a trailing linefeed, and the outer one, >, prints it without one.

If you're a bit familiar with Retina, you might be wondering what happened to Retina's implicit output. Retina's implicit output works by wrapping the final stage of a program in an output stage. However, Retina doesn't do this, if the final stage is already an output stage. The reason for that is that in a normal program it's more useful to be able to replace the implicit output stage with special one like \ or ; for a single byte (instead of having to get rid of the implicit one with the . flag as well). Unfortunately, this behaviour ends up costing us two bytes for the quine.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

21

Javascript (36 char)

(function a(){alert("("+a+")()")})()

This is, AFAICT, the shortest javascript quine posted so far.

Peter Olson

Posted 2011-01-28T00:34:05.293

Reputation: 7 412

7To be pedantic, though, this is only a quine if your JavaScript implementation stringifies the function a exactly the same way as it's been written above. However, the output of this code is likely to be a quine on any JavaScript implementation. – Ilmari Karonen – 2012-02-03T18:55:03.267

1Here is the same quine, 1 byte shorter: !function a(){alert("!"+a+"()")}(). – Ismael Miguel – 2015-02-27T01:22:41.127

@IlmariKaronen Sorry to interrupt, but this is a way to read your own source code! – Erik the Outgolfer – 2016-06-15T08:13:27.717

Same, but output to console: (function a(){return "("+a+")()"})() – Elist – 2017-02-18T21:34:24.850

With lambda (a=()=>alert('('+a+')'))(); – Dennis C – 2017-05-22T05:35:16.187

1(a=()=>alert((${a})))() – Dennis C – 2017-05-22T05:40:51.270

@IlmariKaronen not exactly. If an other implementation chooses to add a space between the arguments and the body, the output is not a quine in an implementation that doesn't add a space between the arguments and body. – Johannes Kuhn – 2013-12-21T20:59:21.210

@JohannesKuhn: I meant that, for any given JavaScript implementation, the output of running the above code on that implementation is likely to be a quine on that implementation. Sorry for the imprecise language. – Ilmari Karonen – 2013-12-21T21:22:09.017

Ok, "However, the output of this code is likely to be a quine on that JavaScript implementation." – Johannes Kuhn – 2013-12-21T21:43:31.820

@DennisC () could be replaced with k to save another byte – Max – 2018-07-22T12:18:08.870

@Max Do you mean (a=k=>alert(\(a=${a})()`))()` – Dennis C – 2018-07-22T14:42:04.190

@DennisC precicely – Max – 2018-07-22T15:09:14.443

1That... is impressive. You should explain how it works for me 8-| – TehShrike – 2011-09-27T19:18:19.643

3@TehShrike Hint: you can view the contents a function by coercing it to a string. For example, if you have a function a, you can access its contents by calling a.toString. – Peter Olson – 2011-09-27T19:22:01.147

19

Lost, 293 262 249 bytes

>:2+52*:6*:(84*+75*):>:::::[[[[[[[:[(52*)>::::[[[[[[:[84*+@>%?!<((((((((((([[[[[[[[[[[[[[ "
\#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\

Try it online!

Explanation

This entire project has been an up and down. I kept thinking it was impossible and then coming up with a crazy idea that just might work.

Why is a Lost Quine so hard?

As you may know Lost is a 2D programming language where the start location and direction are entirely random. This makes writing any lost program about as difficult as writing radiation hardened code. You have to consider every possible location and direction.

That being said there are some standard ways to do things. For example here is the standard way of printing a string.

>%?"Stringv"(@
^<<<<<<<<<<<<<

This has a collection stream at the bottom that grabs the most of the ips and pulls them to the start location. Once they reach are start location (upper left) we sanitize them with a loop getting rid of all the values on the stack then turn the safety of push the string and exit. (safety is a concept unique to Lost every program must hit a % before exiting, this prevents the possibility of the program terminating upon start). Now my idea would be to extend this form into a full fledged quine.

The first thing that had to be done was to rework the loop a bit, the existing loop was specific to the String format.

>%?!<"Stringv"(@
^<<<<<<<<<<<<<<<
^<<<<<<<<<<<<<<<

We need to add a second stream to avoid the possibility of the ! jumping over the stream and creating a loop.

Now we want to mix this with the standard Quine format. Since Lost is based very much on Klein I've basically stolen borrowed the Klien Quine for Martin Ender.

:2+@>%?!< "
<<<<^<<<<<<
<<<<^<<<<<<

This quite conveniently prints the first line of the quine. Now all we need to do is hard-code the streams. Well this is easier said than done. I tried approximately four different methods of doing this. I'll just describe the one that worked.

The idea here is to use doors to get the desired number of arrows. A Door is a special type of mirror that changes every time it is hit. [ reflects ips coming from the left and ] from the right. When they are hit by an ip from either of these sides the switch orientation. We can make a line of these doors and a static reflector to repeatedly perform an operation.

>:[[[

Will perform : three times. This way if we push a < to the stack before hand we can make a lot of them with less bytes. We make 2 of these, one for each line, and in between them we lay down a newline, however the second one needs only go until it covers the ! we added it for, anything else can be left empty saving us a few bytes. Ok now we need to add the vertical arrows to our streams. This is where the key optimization comes in. Instead of redirecting all the ips to the "start" of the program directly we will instead redirect them to the far left, because we already know that the ips starting in far left must work (or at least will work in the final version) we can also just redirect the other ips. This not only makes it cheaper in bytes, I think this optimization is what makes the quine possible.

However there are still some problems, the most important one being ips starting after the > has been pushed but before we start making copies of it. Such ips will enter the copier and make a bunch of copies of 0. This is bad because our stack clearing mechanism uses zeros to determine the bottom of the stack, leaving a whole bunch of zeros at the bottom. We need to add a stronger stack sanitation method. Since there is no real way of telling if the stack is empty, we will simply have to attempt to destroy as many items on the stack as possible. Here we will once again use the door method described earlier. We will add ((((((((((([[[[[[[[[[[[[[ to the end of the first line right after the sanitizor to get rid of the zeros.

Now there is one more problem, since we redirected our streams to the upper left ips starting at the % and moving down will already have turned the safety off and will exit prematurely. So we need to turn the safety off. We do this by adding a # to the stream, that way ips flowing through the stream will be turned off but ips that have already been sanitized will not. The # must also be hard coded into the first line as well.

That's it, hopefully you understand how this works now.

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

:/ so many typos and missing links – ASCII-only – 2017-08-22T07:28:36.653

19

Labyrinth, 124 110 53 bytes

Thanks to Sp3000 for golfing off 9 bytes, which allowed me to golf off another 7.

44660535853919556129637653276602333!
1
:_98
/8 %
@9_.

Try it online!

Explanation

Labyrinth 101:

  • Labyrinth is a stack-based 2D language. The stack is bottomless and filled with zeroes, so popping from an empty stack is not an error.
  • Execution starts from the first valid character (here the top left). At each junction, where there are two or more possible paths for the instruction pointer (IP) to take, the top of the stack is checked to determine where to go next. Negative is turn left, zero is go forward and positive is turn right.
  • Digits in the source code don't push the corresponding number – instead, they pop the top of the stack and push n*10 + <digit>. This allows the easy building up of large numbers. To start a new number, use _, which pushes zero.
  • " are no-ops.

First, I'll explain a slightly simpler version that is a byte longer, but a bit less magical:

395852936437949826992796242020587432!
"
:_96
/6 %
@9_.

Try it online!

The main idea is to encode the main body of the source in a single number, using some large base. That number can then itself easily be printed back before it's decoded to print the remainder of the source code. The decoding is simply the repeated application of divmod base, where print the mod and continue working with the div until its zero.

By avoiding {}, the highest character code we'll need is _ (95) such that base 96 is sufficient (by keeping the base low, the number at the beginning is shorter). So what we want to encode is this:

!
"
:_96
/6 %
@9_.

Turning those characters into their code points and treating the result as a base-96 number (with the least-significant digit corresponding to ! and the most-significant one to ., because that's the order in which we'll disassemble the number), we get

234785020242697299628949734639258593

Now the code starts with a pretty cool trick (if I may say so) that allows us to print back the encoding and keep another copy for decoding with very little overhead: we put the number into the code in reverse. I computed the result with this CJam script So let's move on to the actual code. Here's the start:

395852936437949826992796242020587432!
"

The IP starts in the top left corner, going east. While it runs over those digits, it simply builds up that number on top of the stack. The number itself is entirely meaningless, because it's the reverse of what we want. When the IP hits the !, that pops this number from the stack and prints it. That's all there is to reproducing the encoding in the output.

But now the IP has hit a dead end. That means it turns around and now moves back west (without executing ! again). This time, conveniently, the IP reads the number from back to front, so that now the number on top of the stack does encode the remainder of the source.

When the IP now hits the top left corner again, this is not a dead end because the IP can take a left turn, so it does and now moves south. The " is a no-op, that we need here to separate the number from the code's main loop. Speaking of which:

...
"
:_96
/6 %
@9_.

As long as the top of the stack is not zero yet, the IP will run through this rather dense code in the following loop:

"
>>>v
^< v
 ^<<

Or laid out linearly:

:_96%._96/

The reason it takes those turns is because of Labyrinth's control flow semantics. When there are at least three neighbours to the current cell, the IP will turn left on a negative stack value, go ahead on a zero and turn right on a positive stack value. If the chosen direction is not possible because there's a wall, the IP will take the opposite direction instead (which is why there are two left turns in the code although the top of the stack is never negative).

The loop code itself is actually pretty straightforward (compressing it this tightly wasn't and is where Sp3000's main contribution is):

:    # Duplicate the remaining encoding number N.
_96  # Push 96, the base.
%.   # Take modulo and print as a character.
_96  # Push 96 again.
/    # Divide N by 96 to move to the next digit.

Once N hits zero, control flow changes. Now the IP would like to move straight ahead after the / (i.e. west), but there's a wall there. So instead if turns around (east), executes the 6 again. That makes the top of the stack positive, so the IP turns right (south) and executes the 9. The top of the stack is now 69, but all we care about is that it's positive. The IP takes another right turn (west) and moves onto the @ which terminates the code.

All in all, pretty simple actually.

Okay, now how do we shave off that additional byte. Clearly, that no-op seems wasteful, but we need that additional row: if the loop was adjacent to the number, the IP would already move there immediately instead of traversing the entire number. So can we do something useful with that no-op.

Well, in principle we can use that to add the last digit onto the encoding. The encoding doesn't really need to be all on the first line... the ! just ensures that whatever is there also gets printed there.

There is a catch though, we can't just do this:

95852936437949826992796242020587432!
3
:_96
/6 %
@9_.

The problem is that now we've changed the " to a 3, which also changes the actual number we want to have. And sure enough that number doesn't end in 3. Since the number is completely determined by the code starting from ! we can't do a lot about that.

But maybe we can choose another digit? We don't really care whether there's a 3 in that spot as long as we end up with a number that correctly encodes the source. Well, unfortunately, none of the 10 digits yields an encoding whose least-significant digit matches the chosen one. Luckily, there's some leeway in the remainder of the code such that we can try a few more encodings without increasing the byte count. I've found three options:

  1. We can change @ to /. In that case we can use any digit from 1357 and get a matching encoding. However, this would mean that the program then terminates with an error, which is allowed but doesn't seem very clean.
  2. Spaces aren't the only "wall" characters. Every unused character is, notably all letters. If we use an upper case letter, then we don't even need to increase the base to accommodate it (since those code points are below _). 26 choices gives plenty of possibilities. E.g. for A any odd digit works. This is a bit nicer, but it still doesn't seem all that elegant, since you'd never use a letter there in real code.
  3. We can use a greater base. As long as we don't increase the base significantly, the number of decimal digits in the encoding will remain the same (specifically, any base up to 104 is fine, although bases beyond 99 would actually require additional characters in the code itself). Luckily, base 98 gives a single matching solution: when we use the digit 1, the encoding also ends in 1. This is the only solution among bases 96, 97, 98, 99, so this is indeed very lucky. And that's how we end up with the code at the top of this answer.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

19

GolfScript, 8 bytes

I always thought the shortest (true) GolfScript quine was 9 bytes:

{'.~'}.~

Where the trailing linefeed is necessary because GolfScript prints a trailing linefeed by default.

But I just found an 8-byte quine, which works exactly around that linefeed restriction:

":n`":n`

Try it online!

So the catch is that GolfScript doesn't print a trailing linefeed, but it prints the contents of n at the end of the program. It's just that n contains a linefeed to begin with. So the idea is to replace that with the string ":n`", and then stringifying it, such that the copy on the stack prints with quotes and copy stored in n prints without.

As pointed out by Thomas Kwa, the 7-byte CJam quine can also be adapted to an 8-byte solution:

".p"
.p

Again, we need the trailing linefeed.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

6Golfscript is weird. – CalculatorFeline – 2016-03-23T04:27:50.910

17

Fueue, 423 bytes

Fueue is a queue-based esolang in which the running program is the queue.

)$$4255%%1(~):[)$$24%%0:<[~:)~)]~[$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]](H-):~:[)[):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]~:](106328966328112328136317639696111819119696281563139628116326221310190661962811611211962861109696289611619628116111612896281115421063633063961111116163963011632811111819159628151213262722151522061361613096119619190661966311961128966130281807072220060611612811961019070723232022060611

Try it online!

How it works

This explanation may or may not have got way out of hand. On the other hand I don't know how to explain it much shorter in a way I hope people can follow.

Fueue cheat sheet

See esolang wiki article for details, including the few features not used in this program.

  • The initial program is the initial state of the queue, which can contain the following elements:

    • Integer literals (only non-negative in the source, but negative ones can be calculated), executing them prints a character.
    • Square-bracket delimited nested blocks, inert (preserved intact unless some function acts upon them).
    • Functions, their arguments are the elements following them immediately in the queue:
      • +*/-%: integer arithmetic (- is unary, % logical negation). Inert if not given number arguments.
      • ()<: put element in brackets, remove brackets from block, add final element to block. The latter two are inert unless followed by a block.
      • ~:: swap, duplicate.
      • $: copy (takes number + element). Inert before non-number.
      • H: halt program.

    Note that while [] nest, () don't - the latter are simply separate functions.

Execution trace syntax

Whitespace is optional in Fueue, except between numerals. In the following execution traces it will be used to suggest program structure, in particular:

  • When a function executes, it and its arguments will be set off from the surrounding elements with spaces. If some of the arguments are complicated, there may be a space between them as well.
  • Many execution traces are divided into a "delay blob" on the left, separated from a part to the right that does the substantial data manipulation. See next section.

Curly brackets {} (not used in Fueue) are used in the traces to represent the integer result of mathematical expressions. This includes negative numbers, as Fueue has only non-negative literals – - is the negation function.

Various metavariable names and ... are used to denote values and abbreviations.

Delaying tactics

Intuitively, execution cycles around the queue, partially modifying what it passes through. The results of a function cannot be acted on again until the next cycle. Different parts of the program effectively evolve in parallel as long as they don't interact.

As a result, a lot of the code is devoted to synchronization, in particular to delaying execution of parts of the program until the right time. There are a lot of options for golfing this, which tends to turn those parts into unreadable blobs that can only be understood by tracing their execution cycle by cycle.

These tactics won't always be individually mentioned in the below:

  • )[A] delays A for a cycle. (Probably the easiest and most readable method.)
  • ~ef swaps the elements e and f which also delays their execution. (Probably the least readable, but often shortest for minor delays.)
  • $1e delays a single element e.
  • - and % are useful for delaying numbers (the latter for 0 and 1.)
  • When delaying several equal elements in a row, : or $ can be used to create them from a single one.
  • (n wraps n in brackets, which may later be removed at convenience. This is particularly vital for numeric calculations, since numbers are too unstable to even be copied without first putting them in a block.

Overall structure

The rest of the explanation is divided into seven parts, each for a section of the running program. The larger cycles after which most of them repeat themselves will be called "iterations" to distinguish them from the "cycles" of single passes through the entire queue.

Here is how the initial program is divided between them:

A:  )$$4255%%1(~
B:  ):[)$$24%%0:<[~:)~)]~[$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]
C:  
D:  (H-
E:  
F:  
G:  ):~:[)[):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]~:](106328966328112328136317639696111819119696281563139628116326221310190661962811611211962861109696289611619628116111612896281115421063633063961111116163963011632811111819159628151213262722151522061361613096119619190661966311961128966130281807072220060611612811961019070723232022060611

The big numeral at the end of the program encodes the rest in reverse, two digits per character, with 30 subtracted from each ASCII value (so e.g. 10 encodes a (.)

On a higher level you can think of the data in this program (starting with the bignum) as flowing from right to left, but control flowing from left to right. However, at a lower level Fueue muddles the distinction between code and data all the time.

  • Section G decodes the bignum into ASCII digits (e.g. digit 0 as the integer 48), splitting off the least significant digits first. It produces one digit every 15 cycles.
  • Section F contains the produced digit ASCII values (each inside a block) until section E can consume them.
  • Section E handles the produced digits two at a time, pairing them up into blocks of the form [x[y]], also printing the encoded character of each pair.
  • Section D consists of a deeply nested block gradually constructed from the [x[y]] blocks in such a way that once it contains all digits, it can be run to print all of them, then halt the entire program.
  • Section C handles the construction of section D, and also recreates section E.
  • Section B recreates section C as well as itself every 30 cycles.
  • Section A counts down cycles until the last iteration of the other sections. Then it aborts section B and runs section D.

Section A

Section A handles scheduling the end of the program. It takes 4258 cycles to reduce to a single swap function ~, which then makes an adjustment to section B that stops its main loop and starts running section D instead.

)$ $4255% %1 (~
)$%%%...%% %0 [~]
)$%%%...% %1 [~]
⋮
)$ %0 [~]
) $1[~]
)[~]
~
  • A $ function creates 4255 copies of the following % while the ( wraps the ~ in brackets.
  • Each cycle the last % is used up to toggle the following number between 0 and 1.
  • When all %s are used up, the $1 creates 1 copy of the [~] (effectively a NOP), and on the next cycle the ) removes the brackets.

Section B

Section B handles regenerating itself as well as a new iteration of section C every 30 cycles.

) : [)$$24%%0:<[~:)~)]~[$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]
) [)$$24%%0:<[~:)~)]~[$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]            [BkB]
)$ $24%     %0  :<  [~:)~)]    ~ [$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<] [BkB]
)$ %...%%% %1   < < [~:)~)] [BkB]   [$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]
)$ %...%% %0      < [~:)~)[BkB]] [$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]
)$ %...% %1         [~:)~)[BkB][$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]
⋮
) $1 [~:)~)[BkB][$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]
) [~:)~)[BkB][$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]                    (1)
~:) ~)[BkB]                 [$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]
) : [BkB]                 ) [$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]      (2)
) [BkB] [BkB]               $11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<
  • A : duplicates the big block following (one copy abbreviated as [BkB]), then ) removes the brackets from the first copy.
  • $$24%%0 sets up a countdown similar to the one in section A.
  • While this counts down, :< turns into <<, and a ~ swaps two of the blocks, placing the code for a new section C last.
  • The two < functions pack the two final blocks into the first one - this is redundant in normal iterations, but will allow the ~ from section A to do its job at the end.
  • (1) When the countdown is finished, the ) removes the outer brackets. Next ~:) turns into ): and ~) swaps a ) to the beginning of the section C code.
  • (2) Section B is now back at its initial cycle, while a ) is just about to remove the brackets to start running a new iteration of section C.

In the final iteration, the ~ from section A appears at point (1) above:

~ ) [~:)~)[BkB][$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]                  (1)
[~:)~)[BkB][$11~)~<[[+$4--498+*-:~-10)):])<~][)))~]<]]              )

The ~ swaps the ) across the block and into section C, preventing section B from being run again.

Section C

Section C handles merging new digit character pairs into section D's block, and also creating new iterations of section E.

The below shows a typical iteration with x and y representing the digits' ASCII codes. In the very first iteration, the incoming "D" and "E" elements are the initial [H] and - instead, as no previous section E has run to produce any digit character pairs.

C                                               D             E
$11~ )  ~<[[+$4--498+*-:~-10)):])<~]  [)))~]  < [)))~[...]]   [x[y]]
~~~ ~~~ ~~~ ~~) [[+$4--498+*-:~-10)):])<~]  < [)))~] [)))~[...][x[y]]]
~~~ ~~~     )  ~ [[+$4--498+*-:~-10)):])<~] [)))~[)))~[...][x[y]]]]
~~~       ~ )   [)))~[....]]                                  [[+$4--498+*-:~-10)):])<~]
                                              ~~[)))~[....]] )[[+$4--498+*-:~-10)):])<~]
                                                [)))~[....]]  ~[+$4--498+*-:~-10)):])<~
  • This uses a different method of synchronization which I discovered for this answer. When you have several swap functions ~ in a row, the row will shrink to approximately 2/3 each cycle (because one ~ swaps two following), but occasionally with a remainder of ~s that wreaks havoc on carefully manipulates what follows.
  • $11~ produces such a row. The next ~ swaps a < across the following block. Another < at the end appends a new digit pair block (digits x and y as ASCII codes) into the section D block.
  • Next cycle, the ~ row has a ~~ remainder, which swaps a ~ over the following ). The other < appends section D to a [)))~] block.
  • Next the swapped ~ itself swaps the following block with new section E code across the section D block. Then a new leftover ~ swaps a ) across, and finally the last ~~ in the ~ row swap one of them across to section E just as the ) has removed its brackets.

In the final iteration, section A's ~ has swapped a ) across section B and into section C. However, section C is so short-lived that it already has disappeared, and the ) ends up at the beginning of section D.

Section D

Section D handles printing the final big numeral and halting the program. During most of the program run, it is an inert block that sections B–G cooperate on building.

    (H -
    [H]-
    ⋮
    [)))~[H-]]                  After one iteration of section C
    ⋮
    [)))~[)))~[H-][49[49]]]]    Second iteration, after E has also run
    ⋮
)   [)))~[...]]     [49[48]]    Final printing starts as ) is swapped in
    ))) ~[...][49[48]]
    )) )[49[48]] [...]
    )) 49 [48][...]             Print first 1
    ) )[48] [...]
    ) 48 [...]                  Print 0
    )[...]                      Recurse to inner block
    ...
    ⋮
    )[H-]                       Innermost block reached
    H -                         Program halts
  • In the first cycle of the program, a ( wraps the halting function H in brackets. A - follows, it will be used as a dummy element for the first iteration instead of a digit pair.
  • The first real digit pair incorporated is [49[49]], corresponding to the final 11 in the numeral.
  • The very last digit pair [49[48]] (corresponding to the 10 at the beginning of the numeral) is not actually incorporated into the block, but this makes no difference as )[A[B]] and )[A][B] are equivalent, both turning into A[B].

After the final iteration, the ) swapped rightwards from section B arrives and the section D block is deblocked. The )))~ at the beginning of each sub-block makes sure that all parts are executed in the right order. Finally the innermost block contains an H halting the program.

Section E

Section E handles combining pairs of ASCII digits produced by section G, and both prints the corresponding encoded character and sends a block with the combined pair leftwards to sections C and D.

Again the below shows a typical iteration with x and y representing the digits' ASCII codes.

E                                                   F
~ [+$4--498+*-:~-10)):] )              <  ~         [y] [x]
) [+$4--498+*-:~-10)):]                   < [x] [y]
+ $4-  - 498  +*- :~ -10 ) )              : [x[y]]
+---  -{-498} +*- ~~{-10} )       ) [x[y]]  [x[y]]
+--    - 498  +*   -{-10}       ~ ) x  [y]  [x[y]]
+-    -{-498} +               * 10 x  )[y]  [x[y]]
+      - 498                    + {10*x} y  [x[y]]
                         + {-498} {10*x+y}  [x[y]]
{10*x+y-498}  [x[y]]
[x[y]]
  • The incoming digit blocks are swapped, then the y block is appended to the x block, and the whole pair block is copied. One copy will be left until the end for sections C and D.
  • The other copy is deblocked again, then a sequence of arithmetic functions are applied to calculate 10*x+y-498, the ASCII value of the encoded character. 498 = 10*48+48-30, the 48s undo the ASCII encoding of x and y while the 30 shifts the encoding from 00–99 to 30–129, which includes all printable ASCII.
  • The resulting number is then left to execute, which prints its character.

Section F

Section F consists of inert blocks containing ASCII codes of digits. For most of the program run there will be at most two here, since section E consumes them at the same speed that G produces them with. However, in the final printing phase some redundant 0 digits will collect here.

[y] [x] ...

Section G

Section G handles splitting up the big number at the end of the program, least significant digits first, and sending blocks with their ASCII codes leftward to the other sections.

As it has no halting check, it will actually continue producing 0 digits when the number has whittled down to 0, until section D halts the entire program with the H function.

[BkG] abbreviates a copy of the big starting code block, which is used for self-replication to start new iterations.

Initialization in the first cycles:

) :~  : [)[):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]~:]  ( 106328966328112328136317639696111819119696281563139628116326221310190661962811611211962861109696289611619628116111612896281115421063633063961111116163963011632811111819159628151213262722151522061361613096119619190661966311961128966130281807072220060611612811961019070723232022060611
)  ~ ~ [)[):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]~:]  [BkG] [10...11]
) [)[):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]~:]     ~ [BkG] [10...11]
) [):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]       ~ : [10...11]  [BkG]

Typical iteration, N denotes the number to split:

) [):~[)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+:5):]        ~ : [N]  [BkG]
) :~ [)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]+ :5 )         : [N]  : [BkG]
)  ~ ~ [)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]  +5 5     ) [N]  [N] [BkG] [BkG]
) [)~:~~([:~)*[):~[$1(+48]):~+]-:~~)10)~~]/]               ~ 10 N  [N] [BkG] [BkG]
) ~:~  ~ ( [:~)*[):~[$1(+48]):~+]-:~~)10)~~]               / N 10  [N] [BkG] [BkG]
)  ~ : [:~)*[):~[$1(+48]):~+]-:~~)10)~~]                 ( {N/10}  [N] [BkG] [BkG]
) [:~)*[):~[$1(+48]):~+]-:~~)10)~~]                    : [{N/10}]  [N] [BkG] [BkG]
:~ )*[):~[$1(+48]):~+]- :~ ~)10 )           ~ ~ [{N/10}]  [{N/10}] [N] [BkG] [BkG]
~~) *[):~[$1(+48]):~+]- ~~10 )             ) [{N/10}]  ~ [{N/10}] [N]  [BkG] [BkG]
)  ~ * [):~[$1(+48]):~+]  -10            ~ ) {N/10}  [N] [{N/10}] [BkG] [BkG]
) [):~[$1(+48]):~+]               * {-10} {N/10}  ) [N]  [{N/10}] [BkG] [BkG]
) :~ [$1(+48]) :~                 + {-10*(N/10)} N  [{N/10}] [BkG] [BkG]
)  ~ ~ [$1(+48]  )                 ~ ~ {N%10}  [{N/10}] [BkG] [BkG]
) [$1(+48]                 ~ ) {N%10}  ~ [{N/10}] [BkG]  [BkG]
$1(                     + 48 {N%10}    ) [BkG]  [{N/10}] [BkG]
                        ( {48+N%10}   BkG [{N/10}] [BkG]            New iteration starts
                        [{48+N%10}]   ....
  • The delay blob here is particularly hairy. However, the only new delaying trick is to use +:5 instead of --10 to delay a 10 two cycles. Alas only one of the 10s in the program was helped by this.
  • The [N] and [BkG] blocks are duplicated, then one copy of N is divided by 10.
  • [{N/10}] is duplicated, then more arithmetic functions are used to calculate the ASCII code of the last digit of N as 48+((-10)*(N/10)+N). The block with this ASCII code is left for section F.
  • The other copy of [{N/10}] gets swapped between the [BkG] blocks to set up the start of a new iteration.

Bonus quine (540 bytes)

)$$3371%%1[~!~~!)!]):[)$$20%%0[):]~)~~[)$$12%%0[<$$7%~~0):~[+----48+*-~~10))]<]<~!:~)~~[40~[:~))~:~[)~(~~/[+--48):]~10]+30])):]]][)[H]](11(06(06(21(21(25(19(07(07(19(61(96(03(96(96(03(11(03(63(11(28(61(11(06(06(20(18(07(07(18(61(11(28(63(96(11(96(96(61(11(06(06(19(20(07(07(18(61(30(06(06(25(07(96(96(18(11(28(96(61(13(15(15(15(15(22(26(13(12(15(96(96(19(18(11(11(63(30(63(30(96(03(28(96(11(96(96(61(22(18(96(61(28(96(11(11(96(28(96(61(11(96(10(96(96(17(61(13(15(15(22(26(11(28(63(96(19(18(63(13(21(18(63(11(11(28(63(63(63(61(11(61(42(63(63

Try it online!

Since I wasn't sure which method would be shortest, I first tried encoding characters as two-digit numbers separated by (s. The core code is a bit shorter, but the 50% larger data representation makes up for it. Not as golfed as the other one, as I stopped when I realized it wouldn't beat it. It has one advantage: It doesn't require an implementation with bignum support.

Its overall structure is somewhat similar to the main one. Section G is missing since the data representation fills in section F directly. However, section E must do a similar divmod calculation to reconstruct the digits of the two-digit numbers.

Ørjan Johansen

Posted 2011-01-28T00:34:05.293

Reputation: 6 914

1You should golf the explanation XD – VFDan – 2019-05-24T19:03:40.500

1)$n[)]( is a byte shorter for the delay counter. – jimmy23013 – 2019-05-25T07:36:36.620

17

Hexagony, 261 bytes, side length 10

113009344778658560261693601386118648881408495353228771273368412312382314076924170567897137624629445942109467..../....%'=g':..\..................\.................\................\...............\..............\.............\............\!$/'?))='%<\..>:;/$;4Q/

Try it online!

Uses the same encoding user202729's answer, but terminates in a divide by zero error.

Formatted, this looks like:

          1 1 3 0 0 9 3 4 4 7
         7 8 6 5 8 5 6 0 2 6 1
        6 9 3 6 0 1 3 8 6 1 1 8
       6 4 8 8 8 1 4 0 8 4 9 5 3
      5 3 2 2 8 7 7 1 2 7 3 3 6 8
     4 1 2 3 1 2 3 8 2 3 1 4 0 7 6
    9 2 4 1 7 0 5 6 7 8 9 7 1 3 7 6
   2 4 6 2 9 4 4 5 9 4 2 1 0 9 4 6 7
  . . . . / . . . . % ' = g ' : . . \
 . . . . . . . . . . . . . . . . . . \
  . . . . . . . . . . . . . . . . . \
   . . . . . . . . . . . . . . . . \  
    . . . . . . . . . . . . . . . \   
     . . . . . . . . . . . . . . \    
      . . . . . . . . . . . . . \
       . . . . . . . . . . . . \
        ! $ / ' ? ) ) = ' % < \
         . . > : ; / $ ; 4 Q /
          . . . . . . . . . .

Try it online!

Some python-like psuedo-code to explain:

n = ridiculously long number
base = 103
print(n)
while n > 0:
    b = 2
    if n%b == 1:
        c = '.'
        print(c)
    else:
        n = n//b
        b = base
        c = chr(n%b + 1)
    print(c)
    n = n//b

I'm using base 103 rather than the optimal base 97 just to make sure the number fully fits the top half of the hexagon and doesn't leave an extra . to encode.

Here's a link to user202729's encoder that I used to get the large number and check that the number actually fit in the hexagon.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

What a shame this doesn't fit in 108 digits.

– NieDzejkob – 2019-09-22T09:51:09.313

17

Yup, 1165 879 606 561 540 522 498 + 7 = 505 bytes

Requires the -cheat flag to allow the definition of aliases.

022222120211111102222122021121202222212021112202222110222212202112110222221202122212022222102222212021222120222221022222102222210222221202222110222211022222210222221022222210222212202222221022221102211110222221022221220222212202112120221111022212202211210222212022222102211120222122022111202222120212212021221202222221022111102221210222122022222102222120212212022221102211110222122022221102222120212212022112120221111022212202112120222212=%;0e-=<;0<-=>;:0~--=1;1>=2;0%{{>0<~{~>~<<}>>>]}>]}${<#}%{@}

Try it online!

Explanation

There are two parts to this (as with most quines). The data:

022222120211111102222122021121202222212021112202222110222212202112110222221202122212022222102222212021222120222221022222102222210222221202222110222211022222210222221022222210222212202222221022221102211110222221022221220222212202112120221111022212202211210222212022222102211120222122022111202222120212212021221202222221022111102221210222122022222102222120212212022221102211110222122022221102222120212212022112120221111022212202112120222212

And the decoder:

=%;0e-=<;0<-=>;:0~--=1;1>=2;0%{{>0<~{~>~<<}>>>]}>]}${<#}%{@}

The data is merely a binary encoding of the decoder (or rather its reverse). Each 0 starts a new character and the 1s and 2s are the 0- and 1-bits, respectively.

Note that 0 is a standard Yup command which pushes a zero, while 1 and 2 are not defined at this point. However, we assign the entire data part to the command % so that the 1 and 2 can remain undefined until % is actually used.

Next, we define some more commands:

0e-=<;
0<-=>;
:0~--=1;
1>=2;

< decrements the top of the stack, > increments it. 1 (somewhat unintuitively) doubles the top of the stack. 2 doubles it and then increments it. Thanks to these definitions, something like 0221111 will actually leave a 48 (110000 in binary) on the stack.

The remaining 32 bytes do the actual decoding in two parts. First we need to reconstruct the data string.

0%                ` Push a zero and then the data.
{                 ` For each value...
  {               `   Until that value is zero...
    >0<~{~>~<<}>  `   divmod 2. The div is the input to the next iteration,
                  `   the mod gives us the next bit.
    >>]           `   Increment twice (gives 2 or 3) and put at the bottom
                  `   of the stack.
  }
  >]              ` Increment the 0 and put it at the bottom as well.
}
$                 ` Reverse the entire stack.
{<#}              ` Decrement and print each number.

And finally, we push the data again and print each value as a character:

%{@}

For future reference, here is a CJam script to encode the data.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

15

Jelly, 3 bytes

”ṘṘ

Try it online!

Verification

$ echo $LANG
en_US
$ xxd -g 1 quine.jelly
0000000: ff cc cc                                         ...
$ ./jelly f quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...

How it works

”ṘṘ    Main link. No input.

”Ṙ     Set the return value to the character 'Ṙ'.
  Ṙ    Print a string representation of the return value.
       This prints: ”Ṙ
       (implicit) Print the return value.
       This prints: Ṙ

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

Which version of the interpreter does this use? When I test it, it outputs in UTF-8 even though the input is in Jelly's codepage (and the change in encoding would make it not-a-quine). – None – 2016-12-07T13:37:06.863

1

The output's encoding depends on your terminal's settings: if it's set to UTF-x, it uses that; if it's set to anything else, it uses Jelly's code page. On Linux, LANG=en_US achieves just that. https://tio.run/nexus/bash#@@/j6Odum5oXHxrMVVGRoqBbpKBbUKxgY2OjkJaWDAQKdgqFpZl5qXpZqTk5lRA16QqGKIL6@QUl@mAmhFRIQ5ZWqFGA6fr/HwA

– Dennis – 2016-12-07T16:06:16.560

14

dc - 16 characters

[91PP6120568P]dx

Geoff Reedy

Posted 2011-01-28T00:34:05.293

Reputation: 2 828

7There's this for 10: 6581840dnP – Digital Trauma – 2015-02-26T22:22:01.590

2I knew you could print a character based on an ASCII code directly or a number % 256, but not a string using the coefficients of a base 256 polynomial as individual characters. Awesome! – seshoumara – 2016-09-07T10:05:35.093

Same length: [91PP93P[dx]p]dx (taken from Reddit)

– mbomb007 – 2016-10-26T14:53:23.513

14

Fob (135)

In Fob, a language of my own creation from some time ago, I present a rather interesting 135-byte quine:

$$#<&$::#<&$:#<&#<&$:#<=#<&$&//%<//<.&%<<%.%<&>/////%<<%.<&.%<.%/////<&.%<<&/.%%<&>%</%<////<&.%<<%/<&.%%<&>/%//<&.%<</&.%%%<&>>/>>#<=

Hiato

Posted 2011-01-28T00:34:05.293

Reputation: 731

1"If Fob, a lan" – CalculatorFeline – 2017-05-25T01:17:29.810

14

Stax, 10 4 bytes

..SS

Run and debug online!

I have long believed that the 10-byte quine cannot be any shorter until I happen to come across this one while doing another challenge. This one is not extensible while the 10-byte one is.

Explanation

..SS
..S     The string ".S"
   S    Powerset, in dictionary order if the original string is ordered
        In this case, generates [".",".S","S"]
        Implicit flatten and output

Old version, 10 bytes

"34bL"34bL

Run and debug online!

Added for completeness. I thought this is the shortest proper quine in Stax, but the idea is not that exciting and has been extensively used. I tried to come up with a more interesting (but longer) solution but so far to no avail Now there is one, it's even shorter than this.

I would also be happy to offer a bounty to a proper quine in Stax in the packed form.

Explanation

"34bL"        Push that string
      34      Push the quotation mark
        b     Duplicate both elements on stack
         L    Pack all elements to an array
              Implicit output

Finally, an improper quine:

|?            Source of the program

or just

0             Implicitly prints the 0 on the top of stack

Weijun Zhou

Posted 2011-01-28T00:34:05.293

Reputation: 3 396

14

Perl, 30 28 chars

printf+(q(printf+(q(%s))x2))x2

I first posted this one years ago to the Fun With Perl mailing list, and I've been quite fond of it ever since.

You can save two characters if you use qw instead of q:

printf+qw(printf+qw(%s)x2)x2

Ilmari Karonen

Posted 2011-01-28T00:34:05.293

Reputation: 19 513

3This is the shortest Perl quine I'm aware of (which doesn't read $0, that is). – primo – 2013-06-20T12:43:16.543

12

Dodos, 1743 1722 1380 1360 1340 1155 1120 1105 1095 1075 985 bytes

	o	d
	o	e	d
o
	a	3	p
	o	>	>
p
	u	=
	u	=
	=
	=	>
u
	
	
	
	
	
e
	*	*	-	=
	e	>
a
	dot
>
	dab
b
	b	dip
=
	a	b	m
m
	a	>
	a
i
	a	+	=
	>
*
	=	b
	
+
	dip	=	b
	
-
	i	i	+
.
	i	-
2
	i	i	i	i	.
3
	i	2
5
	i	3
d
	*	*	3	-	*	*	2	-	*	+	*	*	3	-	*	*	2	.	*	*	2	-	*	+	3	-	*	+	*	*	2	*	*	*	-	3	*	*	3	.	*	+	*	*	3	-	*	*	.	3	*	*	.	3	*	+	3	.	*	+	*	*	3	3	*	*	.	2	*	+	*	*	3	3	*	*	.	2	*	+	*	*	.	2	*	+	*	*	.	2	*	*	.	3	*	+	3	3	*	+	*	*	*	+	*	*	*	+	*	*	*	+	*	*	*	+	*	*	*	+	2	.	*	+	*	*	-	*	*	*	-	*	*	*	-	-	*	*	.	2	*	+	*	*	2	.	*	*	.	3	*	+	2	*	*	+	*	*	2	-	3	-	3	2	*	+	.	3	*	+	*	*	2	-	2	*	2	+	*	+	2	+	*	+	*	*	2	+	*	*	2	-	2	2	3	.	*	+	.	2	*	+	*	*	2	*	*	*	2	+	*	*	3	+	*	+	3	+	*	+	*	*	2	*	*	*	.	3	*	+	*	*	2	*	*	+	2	2	*	+	*	*	2	*	*	*	-	+	*	*	.	2	*	+	*	*	.	3	*	+	-	*	*	+	*	*	.	2	*	*	2	+	*	+	*	*	*	+	-	+	*	+	*	*	2	-	2	2	3	.	*	*	.	2	*	*	2	+	*	+	*	*	*	+	-	-	*	+	*	*	2	2	*	*	2	2	*	*	-	+	*	+	-	.	*	+	*	*	2	2	*	*	-	-	*	+	-	2	*	+	*	*	2	2	*	*	2	2	*	*	2	2	*	*	2	2	*	*	-	.	*	+	-	3	*	+	*	*	2	2	*	*	-	2	*	+	.	*	*	+	*	*	2	2	*	*	-	3	*	+	2	-	*	+

Try it online!

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

Why did you use tabs instead of spaces in the last line? – user202729 – 2018-03-18T01:31:50.060

It's easier to print here, because I have a function - that prepends 9 to the argument vector. – Dennis – 2018-03-18T01:39:27.023

And now it's all tabs, because encoding the encoded data is shorter than printing it directly. – Dennis – 2018-03-19T02:16:21.510

12

Cubically, 191143 136577 91163 79824 32301 23782 bytes

bzip2 base64:

QlpoOTFBWSZTWSMgFToABO/+gH+v8Axh+v8AxgYAoIAKQAJdwKuVzgxQ1MUB6hoA0GmgGgJT1FTQ
no0T1BgEBkwhgmqSlP0SaekAAANDNNR6giUSNI9IwgYmRiYGk0bAN0SBGEAgAwipuIKA7IAr0BT8
fTJaxJTd/OTv5dAU375w7dKpPdcgU38W3ZxzMysszgCmq8dVJjeCn61Wa1tmVmZ1gplc94KanXgK
cOAKeeFeHf2XHWrLMyzN2ta1qzWZbvDa2srdncCnMFMvDqBTOflgU0CmgU6gU1rcqk8cmYtCraEq
FKwAEaKqDciINVVTgCm214pJTKFMjGGprIlgQhSh8AAjdcACPWrfws5fs4KwtZFUULGPlBwWUWQo
qGxI64evL2PCZJmSklppgmpiUlBJkhQFgWAlKaYCS+ygDZJECsG+CYIJIAVi+p1vkyE47sxkphLQ
aCIqikSFBkERl6ftt99xKSQE0Q4IhIkVmlYztSX3HWMA+VMsrqrboe70pOhdF17QtcGYNScpPTPc
lIkkgGc4wjB9xJJp/Xd/blx283P0/I2BTsBTmqkxVJ0BTf3YCnTr7QU/4u5IpwoSBGQCp0A=

Try it online!

At least it is obviously possible. Didn't try v1.3 yet.

The official interpreter seemed to be lying about that it supports SBCS. But I managed to get it working in Unicode mode.

Generator in CJam

{
e#"«»"[129 130]er
"«»"'Â1$f+ers
}:U;
{
N-U:i_0=\2ewWf%::-+
{
_g:M;
[z
[[36 5]
[29 4]
[25 2]
[23 1]
[21 3]]
{~@@md\@s*\}/
_11>{3 21@-])\s_M" +-"=\+e&\0s*_M" -+"=\+e&+}{0s*]s_M" +-"=\+e&}?
'@
}%s
}:F;

[
""
"M2E
(
!0{LDL'"

"}))"F

"&}
M-"

""
"*1(6/1+"

""

"*1
!0{?6{*11LDL'"

"
?0{/4+11@_}
!0{(6*11+33@/11-4)}
}-1
!6{+":QN-F

"LD'L'/11}}
!6{+"

]_sN-

U,24md23\-'+*@0@t4 2$)"3"*t6@)"3"*t
sN-

_U{i32-"4"*QN-}/"}))"

Pseudocode

Loop i in {1,2,3}
    If i = 3, output "}))" and exit
    n = -1 - length before the first +1+1+1+1+...
    Loop while n != 0:
        n += 1 + length before the first +1+1+1+1+...
        If i = 2, output the code corresponding to the following pseudocode:
            "
                    If i = 1, output n as a character
                    If i = 2, output "+1" n times
                n--

                If n = 0:
                    n =
            "

        If n = 0:
            n = +1+1+1+1+... (the first character)
            If i = 1, output n as a character
            If i = 2, output "+1" n times
        n--

        If n = 0:
            n = +1+1+1+1+... (the second character)
            If i = 1, output n as a character
            If i = 2, output "+1" n times
        n--

        ...

n is stored in the register called "notepad". i is stored as cube positions.

The first version has used a 1 in one face to print numbers. The latest version simply add whatever number in one face and divides by it.

There are two ways of printing a string preserving the register. One way is to multiply by 16 or 32 two times, the other is to shift left by a small number. The cube position had to be chosen carefully to get a small enough number in the first version to prevent overflow. But after it is golfed it almost always works.

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

So... how many chars are there in the program? – user202729 – 2018-03-18T01:23:39.207

Somewhat similar to the Mini-flak quine. – user202729 – 2018-03-18T01:33:22.743

The official interpreter seemed to be lying about that it supports SBCS. shhhhh :P but congrats on winning the bounty! – MD XF – 2018-03-20T03:21:07.770

Yeah, it was lying. I'm too lazy to go fix the repo so I'll delete the meta post until it's fixed. – MD XF – 2018-03-20T03:31:13.427

1@jimmy23013 I'll give you a +100 bounty on another post in honor of this one. (Dennis has said this is allowed.) – MD XF – 2018-03-23T03:52:54.567

12

><> (Fish) - 8 chars

Prints itself but throws an error

"r0:g>o<

13 For no error (old Fish)

"r0:g!;>?o?|;

15 if you think g is cheating

"r1b3*+!;>?o?|;

cthom06

Posted 2011-01-28T00:34:05.293

Reputation: 618

In old fish the ? command did not pop the stack, new fish does – JNF – 2015-05-27T18:53:39.607

I would suggest, for new ><>, "r0:g>o_!~l?!;!_|, or "r13b*+>o_!~l?!;!_| for no g version (which I don't view as cheating anyway...). But then you're not better off from "r00g!;oooooooo| (16) – JNF – 2015-05-27T20:57:16.097

Last two ones don't work for me. They output rg>? and r3!?|, respectively. They seem to skip two characters every time... – tomsmeding – 2013-04-22T05:55:01.833

@tomsmeding I think the interpreter changed some point after this answer, hence the (old fish) in parentheses. Though I honestly can't remember it was 2 years ago. I know they worked when i posted my answer. – cthom06 – 2013-04-22T13:19:16.340

1I've been looking at this for a little bit (longer than I should have!) and I've come up with this quine which errors but doesn't use g; #o<}-1:" respectively; #.09;!?lo}-1:" for the non error one. being 8 bytes and 14 bytes. – Teal pelican – 2016-12-19T14:33:17.830

@Tealpelican brilliant! I never even thought about ' # ' - 1 being ' " ' – cthom06 – 2016-12-20T19:54:56.880

12

Python 3, 54

I have never seen this one before, so here's my fair creation. It is longer than the classical one but it is a single expression.

print(str.format(*['print(str.format(*[{!r}]*2))']*2))

Evpok

Posted 2011-01-28T00:34:05.293

Reputation: 558

@flornquake Then wouldn't it be four bytes shorter, because of the print(...) within the string? – HyperNeutrino – 2016-02-11T23:59:12.553

1@Alex No, because you need to add a space after each print. – flornquake – 2016-02-20T23:04:07.843

@flornquake Right. Thanks. Also, nice username. It's interesting. – HyperNeutrino – 2016-02-21T02:44:29.590

3btw, this is 2 bytes shorter in Python 2, where you don't need the parentheses after print. – flornquake – 2014-09-15T09:40:19.627

12

Haskell (50 characters)

main=putStr$q++show q;q="main=putStr$q++show q;q="

AardvarkSoup

Posted 2011-01-28T00:34:05.293

Reputation: 344

11

7, 2 (or 1⅞ or 1⅝, depending on how you count) bytes

7 is an Underload derivative that I've been working on over the past few days. Being an Underload derivative, it's particularly good at quines, so I thought I'd come to this challenge first. (Unlike Underload, though, it has support for input. Like Underload, it's Turing-complete, thus meaning it can handle all the tasks required to be an actual programming language.)

The program itself can be expressed either in octal encoding (there are only 8 commands, named 0, 1, 2, 3, 4, 5, 6, and 7, that can appear in a 7 source file):

23723

or packed into bytes (the language sees them as raw octets; I've expressed them as codepage 437 here):

(The interpreter ignores trailing 1 bits, so arguably this program can be golfed down to only 13 bits = 1⅝ bytes long via removing the language's equivalent of "trailing whitespace". Languages like this are a little hard to count.)

Here's how the program works. 2 encodes "duplicate", 3 encodes "output and pop twice", thus the combination 23 means "output and pop". The program will thus start by pushing two 23 units on the stack (these are initially inert, but become active as they're pushed). Because the end of the program was reached, it's replaced by the top stack element, without disturbing the stack; thus the text of the second 23 gets output and popped. (As it's active rather than inert, what actually gets output is a string representation, 723, but the first 7 is interpreted as a formatting code that specifies "the output should be in the same encoding as the program itself", meaning that the quine works in both encodings.) Then the same thing happens for the first 23; this time, the whole 723 gets output, leading to an output of 23723 (or ).

This is a true quine via all the definitions we commonly use on SE. For example, the first 23 encodes the second 23 and vice versa, meaning that part of the program encodes a different part of the output. Likewise, this quine could handle a payload just fine. If you didn't require a true quine, you could use the following ⅜-byte program:

3

which is a proper quine by some definitions, but not others. (The stack starts with two bars on it, meaning that the extra pop that occurs after the output is printed is harmless.)

user62131

Posted 2011-01-28T00:34:05.293

Reputation:

http://codegolf.stackexchange.com/a/55943/42545 I should've implemented it sooner ;-) – ETHproductions – 2016-12-04T04:32:32.530

Not really a big deal to have two languages with the same name. It's happened before.

– None – 2016-12-04T04:34:34.193

You can only claim byte counts that are supported by an implementation. Unless 7 is implemented on a system that stores raw bits, the byte count for this answer should be 2. – Dennis – 2016-12-06T19:13:39.607

@Dennis: The language's implementation ignores any 1 bits at the end of the program, throwing them away as it reads them; they're just padding to allow the language to be stored on a disk (in much the same way as some older computer systems couldn't read files in units smaller than, say, 80 bytes). Do you consider that to count? – None – 2016-12-06T19:48:09.730

Whether the bits are ignored by the interpreter are irrelevant; what counts is the size of the source code. Unless you can actually save your source code using only 15 bits, the byte count is 2. – Dennis – 2016-12-06T19:51:20.687

1I'll mark it as 2 bytes for the time being, then, but this probably deserves a meta post of its own for discussion. – None – 2016-12-06T19:55:23.920

I love it. 7th upvote btw ;) – FatalMerlin – 2017-04-26T11:46:33.030

11

Triangular, 18337

...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828<>HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp...HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH``

Since this contains un-printables here's a pastebin. Try it online!

Explanation

Here is the relevant portion of the code with a line breaks where they would be inserted:

  ,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828<
 >HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp...HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH`
`

The Hs are there because they are easier to print than ., but they have the same function, so I'll replace them and all the other noops with .:

  ,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828<
 >................................................33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp.................................................`
`

Like most quines this comes in two parts, an encoder and a decoder. The encoder is the line full of numbers and the decoder is the line full of symbols. Each pair of numbers in the encoder represents a single character in the decoder. Once we have encoded we get pushed down to the decoder.

The first thing in the encoder (besides 33pp which is just there for spacing) is ). This tells triangular to jump back to the start of the most recent loop. However since we have not opened a loop there is nothing to go back to so it does nothing. This will be used later to yoyo the ip when we don't want it to run the decoder.

We then store - to the register with 95*P, this will be used to create both , and .. We then push 189 which is the number of blank lines before the code starts. We use this and a loop to generate all the empty lines before the code starts.

(:(dUi@p]pd]

Once our loop is done we add the , with pUd@p. Now we are ready to decode the encoder, this is done with the simple loop:

(%p%p]

Each %p prints one of the numbers off the top of the stack. We have two of them because some of the numbers have zero as their second digit, meaning in order to get the loop to go through all the encoder we need to print them two at a time.

Once the encoder has been printed we print <> which makes up the two redirects that are needed.

562**@2+@p

Now we need to fetch another copy of the encoder. To start we open a loop with ( this will be closed by the ) we encountered earlier allowing us to spring back to where we were first.

But first we have to run through the decoding section once. The decoding section combines the two numbers as a double digit number in base 10 and adds 18 to the result, since our stack is currently empty this will decode to 18 directly. Thats what accounts for the unprintable in the quine. Once we have "decoded" a character we run through the bit of the program that creates the padding, we make half the padding and leave the other half to be made later. Next up we is the code that makes the backticks. Since we absolutely cannot have any of these just lying around we subtract the register from the result to makes some significantly less harmful 3s. Lastly we use the check the contents of the register, exiting on zero. Since we don't have anything we continue on for later. In order to make sure the next run does terminate we put a 0 in the register.

The ip runs through the encoder again and gets yoyo'd back to our decoder again.

Now we are ready to decode everything. The first loop

(9i*+92*+@p]p

Converts to base 10 adds 18 and outputs, it does this until we have emptied the stack.

Next up we create the padding. We already created half the padding the first run through so we only have half left.

86*dd(d89*@p]p

Once again we pad with H because its cheaper to make than . in this situation.

Now we make the backticks. We make them using 843** and subtract the contents of the register using U-, since we previously set the register to zero we output backtick this time.

Now we exit by checking the contents of the register:

U0P!&

(there are also 3 ps at the end of the code, I don't know why they need to be there but they do, a bunch of weird characters end up in the output otherwise)

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

11

Amazon Alexa, 31 words

Alexa, Simon Says Alexa, Simon Says
Alexa, Repeat That
Alexa, Simon Says Alexa, Repeat That Alexa, Simon Says, Alexa, Repeat That Alexa, Simon Says
Alexa, Repeat That
Alexa, Simon Says quiet

(each command is on a newline)

When said out loud to a device with the Amazon Alexa digital assistant enabled (I've only tested this on the Echo Dot though), it should say the same words back to you. There will be some different lengths of pauses between words, as you wait for Alexa to reply, and it says everything without breaks, but the sequence of words are the same.

Explanation:

Each line is a new Alexa command, one of either:

  • Alexa, Simon Says ..., which will prompt Alexa to say everything afterward the command
  • Alexa, Repeat That, which repeats the last thing Alexa said

(neither of these appear on most lists of Alexa commands, so I hope someone has actually learned something from this)

We can simplify this to the commands S and R respectively, separated by spaces. For example, SR will represent Alexa, Simon Says Alexa, Repeat That. The translation of our program would be:

SS R SRSRS R SQ

Where Q is quiet (but can be anything. I chose quiet because that's what Alexa produced when I tried to give it quine, and it fit, so I kept it). Step by step, we can map each command to the output of each command:

Commands: SS
Output:   S
Commands: SS R
Output:   S  S
Commands: SS R SRSRS
Output:   S  S RSRS
Commands: SS R SRSRS R
Output:   S  S RSRS  RSRS
Commands: SS R SRSRS R    SQ
Output:   S  S RSRS  RSRS Q
Total Commands: SSRSRSRSRSQ
Total Output:   SSRSRSRSRSQ

The general approach for this was to get the output ahead of the input commands. This happens on the second to last command, which gets an extra S command. First we have to get behind on output though. The first two commands SS R only produce SS, leaving us to make up the R. However, this allows us to start a S command with an R, which means we can repeat a section (RSRS) multiple times, which allows us to get the spare S leftover. After that, all we had to do was use it to say whatever we wanted.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

1Can Alexa do addition and primality checks? If so, then Alexa is a programming language according to PPCG – MilkyWay90 – 2019-03-26T00:27:54.330

2@MilkyWay90 Yes, Alexa can do both those things, but I still hesitate to call it a programming language since those are both "built-ins", and Alexa is incapable of basic data storage and input. – Jo King – 2019-04-15T05:49:47.653

1This is really a nice idea, but i don't think that it would be a valid quine if it is a valid programming language. In a valid quine, the spaces (or pauses) must also be the same, so if you had a second Alexa which only hears the output of the first Alexa, it should say the same as the first Alexa for a valid quine.

The different pauses lead to different commands. You enter S("S"); R(); S("RSRS"); R(); S(); and you get S(); S(); R("SRS"); R("SRS"); – Dorian – 2019-06-03T11:00:06.757

I disagree. Each line of a quine isn't required to output itself. In an arbitrary scripting language, A\nB\n would be a valid quine even if A output nothing then B output A\nB\n. most multi-instruction quines don't output anything until the last line [of each loop]. – Sparr – 2019-09-24T18:49:46.560

10

Threead, 85 bytes

>93>60>111>99>91>60>93>62>111>100>111>99>50>54>105>91>62>93>60>91[<]>[i62codo>]<[co<]

Try it online!

>93>60>...60>91      # Encodes the second part backwards
[<]>                 # Go back to the begining
    [        ]       # for every number
     i               # insert an extra cell
      62co           # print a '>' 
          d          # delete the cell
           o         # print the original number in this cell
            >        # go to the next cell
              <[  <] # for every cell in reverse order
                co   # print the character that it represents

Riley

Posted 2011-01-28T00:34:05.293

Reputation: 11 345

That's really cool. Explanation to come? – Pavel – 2017-01-13T00:28:12.937

@Pavel Working on it now :) – Riley – 2017-01-13T00:28:39.430

That's, actually much more simple than the solution I had planned. – ATaco – 2017-01-13T00:33:55.597

10

Haskell,  44  41 bytes

EDIT:

  • -3 bytes due to H.PWiz

GHC 8.4.1 is out, which implements the second phase of the Semigroup Monoid Proposal.

As a result, the <> operator is now available without an import, which allows a 9 bytes shorter quine than the previous record, the nearly six year old answer by AardvarkSoup.

main=putStr<>print$"main=putStr<>print$"

Try it online! (This cheats and has an import in the header because TIO hasn't upgraded to GHC 8.4 yet.)

How it works

  • <> is Semigroup multiplication, defined differently for each type it supports.
    • For functions, it returns a new function that takes an argument, passes it to the two multiplied functions, and then applies <> for the result type to the results.
    • For IO actions, it returns a new IO action that runs the two multiplied actions, and then applies <> to their result values to get the result value of the combination.
  • Thus putStr<>print$q = do x <- putStr q; y <- print q; pure (x<>y), which first outputs the string q, then outputs its string literal version with a newline appended. (The result values are both (), so the final one is also (), although this doesn't affect output.)

Ørjan Johansen

Posted 2011-01-28T00:34:05.293

Reputation: 6 914

1

I don't fully understand new stuff. would this be valid?

– H.PWiz – 2018-04-02T02:24:00.970

I figured that if Semigroup was a suprclass of Monoid, then IO () would have to become a Semigroup and <> would work – H.PWiz – 2018-04-02T03:14:52.013

Oh I completely misread what you were asking. I didn't know IO () was a Semigroup. – Ørjan Johansen – 2018-04-02T03:15:55.943

I don't think it is at the moment, so I would have to install the latest version to really check – H.PWiz – 2018-04-02T03:17:04.860

Oh right. It's only a Monoid in TIO's version. – Ørjan Johansen – 2018-04-02T03:17:57.557

1I just installed it, my link is valid for 41 bytes :) – H.PWiz – 2018-04-02T03:25:38.700

10

Shakespeare Programming Language, 327718 292629 bytes

That's about 286 KiB, not 3 MiB.

Because the source code itself is too big, run this Bash program to generate the quine in quine.spl file. Expect .input.tio file to be the input in the TIO link.

cat << 'eof' > convert.ijs
9!:37 (0 _ _ _)

f =: (('the sum ofa cat ' #~ 2&|) , 'twice ' , [: f <.@%&2) ` ('zero'"_) @. (=&0)
g =: ([: toupper 'remember ' , f , '!'"_)"0

inp =: stdin''
inp =: toupper inp rplc LF;' ';'!';'.'
out =: 'LET USSCENE D.' ,~ ; <@g 0, |. -&31 a. i. inp
NB. echo # out
echo out

exit ''
eof

cp .input.tio quine.spl
/opt/j/bin/jconsole convert.ijs < .input.tio | tr -d '\n' >> quine.spl
wc -c quine.spl

/opt/spl/spl2c < quine.spl > quine.spl.c 2> /dev/null
gcc -c -I /opt/spl -o quine.spl.o quine.spl.c
gcc -lm -o quine quine.spl.o /opt/spl/libspl.a

./quine < /dev/null > quine.spl.out

wc -c quine.spl.out

diff quine.spl quine.spl.out

Try it online!


The content of the .input.tio file should be:

T.AJAX,.PAGE,.ACT I:.SCENE I:.[ENTER AJAX AND PAGE]AJAX:LET USSCENE II.SCENE D:.PAGE:REMEMBER A PIG.SCENE C:.AJAX:RECALL.PAGE:REMEMBER I.AJAX:BE YOU NICER ZERO?IF NOTLET USSCENE M.YOU BE THE SUM OFA PIG THE SUM OF A BIG BIG BIG BIG BIG CAT YOU.SPEAK THY.LET USSCENE C.SCENE M:.PAGE:RECALL.BE YOU WORSE ZERO?IF SOLET USSCENE IX.AJAX:YOU BE THE SUM OFTHE SQUARE OFTHE SUM OFA BIG BIG BIG CAT A CAT A CAT.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA BIG BIG CAT A CAT THE CUBE OFA BIG BIG CAT.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG CAT YOU.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG PIG YOU.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG CAT YOU.SPEAK THY.YOU BE THE SUM OFTHE CUBE OFA BIG BIG CAT A BIG CAT.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA CAT YOU A BIG CAT.SPEAK THY.YOU BE THE SUM OFTHE SQUARE ROOT OFTWICE YOU THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE A BIG BIG BIG BIG BIG CAT.SPEAK THY.SCENE V:.PAGE:BE YOU NICER ZERO?IF NOTLET USSCENE X.AJAX:YOU BE THE QUOTIENT BETWEENI A BIG CAT.REMEMBER YOU.BE I NICER TWICE YOU?IF NOTLET USSCENE L.YOU BIG BIG BIG BIG BIG CAT.PAGE:YOU BE TWICE THE SUM OFTWICE THE SQUARE ROOT OFI I.SPEAK THY.YOU BE TWICE THE SUM OFA BIG BIG CAT I.SPEAK THY.YOU BE THE SUM OFTHE SQUARE ROOT OFI TWICE I.SPEAK THY.AJAX:SPEAK THY.PAGE:YOU BE THE SQUARE ROOT OFTHE PRODUCT OFTHE SUM OFYOU I YOU.SPEAK THY.YOU BE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG PIG YOU.SPEAK THY.AJAX:SPEAK THY.PAGE:YOU BE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE TWICE THE SUM OFTHE SUM OFA CAT I A BIG CAT.SPEAK THY.YOU BE THE SUM OFTWICE I A CAT.SPEAK THY.AJAX:SPEAK THY.PAGE:YOU BE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE THE SUM OFTWICE I A CAT.SPEAK THY.YOU BE TWICE THE SUM OFTWICE THE SQUARE ROOT OFI I.SPEAK THY.AJAX:SPEAK THY.SCENE L:.PAGE:YOU BIG BIG BIG CAT.AJAX:YOU BE TWICE THE SUM OFTWICE THE SUM OFTWICE I A CAT I.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA CAT YOU A BIG CAT.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA CAT I THE SQUARE OFI.SPEAK THY.YOU BE THE SUM OFTWICE THE SUM OFA BIG PIG A PIG YOU.SPEAK THY.YOU BE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE TWICE TWICE I.SPEAK THY.RECALL.PAGE:YOU BE I.LET USSCENE V.SCENE X:.PAGE:YOU BIG BIG BIG BIG CAT.AJAX:YOU BE THE SQUARE ROOT OFTWICE THE CUBE OFI.SPEAK THY.YOU BE THE SUM OFTWICE TWICE THE SUM OFA CAT I A CAT.SPEAK THY.YOU BE THE SUM OFTWICE THE SUM OFTWICE I A CAT I.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA PIG YOU A BIG PIG.SPEAK THY.YOU BE THE SUM OFTWICE I A CAT.SPEAK THY.LET USSCENE M.SCENE IX:.PAGE:YOU BE TWICE TWICE THE SUM OFTWICE THE SUM OFA BIG BIG BIG CAT A CAT A CAT.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA CAT YOU A BIG BIG BIG PIG.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG BIG CAT THE SUM OFA PIG YOU.SPEAK THY.YOU BE A BIG BIG BIG BIG BIG CAT.SPEAK THY.YOU BE THE SUM OFTWICE THE SUM OFTWICE THE SQUARE ROOT OFYOU YOU A CAT.SPEAK THY.YOU BE THE SUM OFA BIG PIG YOU.SPEAK THY.YOU BE YOU.SPEAK THY.YOU BE THE SUM OFA BIG BIG BIG BIG PIG YOU.SPEAK THY.YOU BE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA CAT YOU A BIG BIG BIG CAT.SPEAK THY.YOU BE THE SUM OFTHE SUM OFA PIG YOU A BIG BIG BIG PIG.SPEAK THY.YOU BE A BIG BIG BIG BIG BIG CAT.SPEAK THY.YOU BE TWICE THE SUM OFA BIG CAT YOU.SPEAK THY.YOU BE TWICE THE SQUARE ROOT OFTWICE TWICE TWICE YOU.SPEAK THY.RECALL.SCENE II:.AJAX:

which is also the first part of the quine program. The second part is the first part converted through the convert.ijs J script written above.


The constant generation part needs a lot more work.


Each byte in the source code is encoded by:

REMEMBER <repr(value - 31)>.

where:

repr(0) = 'ZERO'
repr(2 * x + 1) = 'THE SUM OFA CAT ' + repr(2 * x)
repr(2 * x) = 'TWICE ' + repr(x)

with integral x.

user202729

Posted 2011-01-28T00:34:05.293

Reputation: 14 620

For the record this one is about 5% of the previous quine (6MiB) (although the other one is not really a serious contender) – user202729 – 2018-05-30T16:06:24.903

1

Some quick golfing to get to 264827 bytes. Pastebin link to TIO link because it doesn't fit in a comment

– Jo King – 2018-05-31T12:07:36.583

10

TI-BASIC

i

Where i is the imaginary number

Timtech

Posted 2011-01-28T00:34:05.293

Reputation: 12 038

1@Timtech The goal is to write the shortest quine. – mbomb007 – 2015-09-14T21:38:00.797

@mbomb007 True, updated. – Timtech – 2015-09-17T23:56:04.503

-1. That doesn't actually print 2i outside of an interactive console, does it? – nyuszika7h – 2014-04-26T15:27:23.670

@nyuszika7h Yes it does. 2i works as a program that, when run, prints 2i (because the last line that sets Ans is automatically printed). – Timtech – 2014-04-26T16:40:56.363

12@nyuszika7h Please test or research before downvoting. – Timtech – 2014-04-26T16:41:19.850

Well, now I can't undo my vote unless this answer is edited. But then couldn't you just use 2 for a 1-byte solution? – nyuszika7h – 2014-04-27T17:46:20.337

@nyuszika7h Yes, but that isn't interesting/obfuscated... – Timtech – 2014-04-27T20:35:11.567

10

A Classic - Lisp - 78

((lambda (x) (list x (list 'quote x))) '(lambda (x) (list x (list 'quote x))))

A beautiful snippet, but give credit where credit is due.

arrdem

Posted 2011-01-28T00:34:05.293

Reputation: 805

9Actually this code returns itself instead of printing itself. Running it in an interpreter with read-eval-print loop will of course print the returned list, but the printing is not part of the code itself. The C equivalent of this would be a C code which outputs its executable instead of its source code. Which would certainly also be a quite interesting problem, although heavily system-dependent. – celtschk – 2012-02-03T16:13:41.650

that would make it not different from one of those function quines – Destructible Lemon – 2017-06-24T08:52:37.490

the link is dead – Def – 2018-01-15T21:02:36.297

The link is indeed dead. The suggested edit adds a link that doesn't help, though. – mbomb007 – 2019-06-10T03:13:27.870

10

Ceylon 1647 1165 885 739 672 566 388 187 178 bytes

Late, and won't win anything ... but I'm trying out how Ceylon works.

An one-liner now:

shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b=""";print(t+q+t+q+";value b="+q+b+q+b);}""";print(t+q+t+q+";value b="+q+b+q+b);}`

The ungolfed original (1647 bytes):

shared void quine69() {
    void printQuoted(String line) => print("        \"" + line + "\"");
    void printQuotedWithComma(String* seq) {
        for (line in seq) {
            print("        \"" + line.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\",");
        }
    }
    void printLines(String* seq) {
        for (line in seq) {
            print(line);
        }
    }
    value top = [
        "shared void quine69() {",
        "    void printQuoted(String line) => print(\"        \\\"\" + line + \"\\\"\");",
        "    void printQuotedWithComma(String* seq) {",
        "        for (line in seq) {",
        "            print(\"        \\\"\" + line.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\",\");",
        "        }",
        "    }",
        "    void printLines(String* seq) {",
        "        for (line in seq) {",
        "            print(line);",
        "        }",
        "    }",
        "    value top = ["
    ];
    value bottom = [
        "    ];",
        "    printLines(*top);",
        "    printQuotedWithComma(*top.exceptLast);",
        "    printQuoted(top.last);",
        "    print(\"    ];\");",
        "    print(\"    value bottom = [\");",
        "    printQuotedWithComma(*bottom.exceptLast);",
        "    printQuoted(bottom.last);",
        "    printLines(*bottom);",
        "}"
    ];
    printLines(*top);
    printQuotedWithComma(*top.exceptLast);
    printQuoted(top.last);
    print("    ];");
    print("    value bottom = [");
    printQuotedWithComma(*bottom.exceptLast);
    printQuoted(bottom.last);
    printLines(*bottom);
}

The second try, mainly with shorter names, and extract the quote function (to 1165 bytes):

shared void q() {
    String q1(String l) => "        \"" + l.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\"";
    void pQ(String l) => print(q1(l));
    void pQC(String* seq) { for (l in seq) { print(q1(l) + ","); } }
    void pL(String* seq) { for (l in seq) { print(l); } }
    value t = [
        "shared void q() {",
        "    String q1(String l) => \"        \\\"\" + l.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\"\";",
        "    void pQ(String l) => print(q1(l));",
        "    void pQC(String* seq) { for (l in seq) { print(q1(l) + \",\"); } }",
        "    void pL(String* seq) { for (l in seq) { print(l); } }",
        "    value t = ["
    ];
    value b = [
        "    ];",
        "    pL(*t);",
        "    pQC(*t.exceptLast);",
        "    pQ(t.last);",
        "    print(\"    ];\");",
        "    print(\"    value b = [\");",
        "    pQC(*b.exceptLast);",
        "    pQ(b.last);",
        "    pL(*b);",
        "}"
    ];
    pL(*t);
    pQC(*t.exceptLast);
    pQ(t.last);
    print("    ];");
    print("    value b = [");
    pQC(*b.exceptLast);
    pQ(b.last);
    pL(*b);
}

The third try omits the indentation (I had to change my IDE settings to turn auto-formatting off). This gets us to 885 bytes:

shared void i() {
String q1(String l) => "\"" + l.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\"";
void pQ(String l) => print(q1(l));
void pQC(String* seq) { for (l in seq) { print(q1(l) + ","); } }
void pL(String* seq) { for (l in seq) { print(l); } }
value t = [
"shared void i() {",
"String q1(String l) => \"\\\"\" + l.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\"\";",
"void pQ(String l) => print(q1(l));",
"void pQC(String* seq) { for (l in seq) { print(q1(l) + \",\"); } }",
"void pL(String* seq) { for (l in seq) { print(l); } }",
"value t = ["
];
value b = [
"];",
"pL(*t);",
"pQC(*t.exceptLast);",
"pQ(t.last);",
"print(\"];\");",
"print(\"value b = [\");",
"pQC(*b.exceptLast);",
"pQ(b.last);",
"pL(*b);",
"}"
];
pL(*t);
pQC(*t.exceptLast);
pQ(t.last);
print("];");
print("value b = [");
pQC(*b.exceptLast);
pQ(b.last);
pL(*b);
}

The fourth version has also the internal spaces, and some line breaks removed, comes down to 739 bytes:

shared void n(){
String q1(String l)=>"\""+l.replace("\\","\\\\").replace("\"","\\\"")+"\"";
void pQ(String l)=>print(q1(l));
void pQC(String*s){for(l in s){print(q1(l)+",");}}
void pL(String*s){for(l in s){print(l);}}
value t=[
"shared void n(){",
"String q1(String l)=>\"\\\"\"+l.replace(\"\\\\\",\"\\\\\\\\\").replace(\"\\\"\",\"\\\\\\\"\")+\"\\\"\";",
"void pQ(String l)=>print(q1(l));",
"void pQC(String*s){for(l in s){print(q1(l)+\",\");}}",
"void pL(String*s){for(l in s){print(l);}}",
"value t=["
];value b=[
"];",
"pL(*t);pQC(*t.exceptLast);pQ(t.last);",
"print(\"];value b=[\");",
"pQC(*b.exceptLast);pQ(b.last);pL(*b);",
"}"
];
pL(*t);pQC(*t.exceptLast);pQ(t.last);
print("];value b=[");
pQC(*b.exceptLast);pQ(b.last);pL(*b);
}

For the next version I tried a different approach, to avoid all this escaping. Ceylon has (like Python) a "long string literal" format – everything between """ and """ is part of a string, with no escapes. ... But the indentation is removed, and because the """ itself is already 3 chars long, we also need at least those the spaces of indentation. For printing this string literal we also need to add those indentation back, and we need to handle the first and last line specially (the first needs to have """ in front, the last one is better omitted, otherwise we get one line more in the output than we already had. This (and replacing some identifiers by one-letter ones) gets us down to 672 bytes:

shared void e(){
value _="   ";value q="\"\"\"";
void r(String? l)=>print(q+(l else""));
void s(String l)=>print(_+q+l);
void c(String*s){for(l in s){print(_+l);}}
value t=

"""shared void e(){
   value _="   ";value q="\"\"\"";
   void r(String? l)=>print(q+(l else""));
   void s(String l)=>print(_+q+l);
   void c(String*s){for(l in s){print(_+l);}}
   value t=
   """;value b=
"""print(t);r(t.lines.first);c(*t.lines.rest.exceptLast);
   s(";value b=");
   r(b.lines.first);c(*b.lines.rest.exceptLast);s(";");print(b);
   }
   """;
print(t);r(t.lines.first);c(*t.lines.rest.exceptLast);
s(";value b=");
r(b.lines.first);c(*b.lines.rest.exceptLast);s(";");print(b);
}

(This has an empty trailing line, which Stack Exchange doesn't show. Same for the next ones.)

By inlining the two short functions r and s (their savings are less than the function definition), and extracting the long .lines.rest.exceptLast expression into the c function, we get down to 566 bytes:

shared void e(){
value _="   ";value q="\"\"\"";
void c(String s){for(l in s.lines.rest.exceptLast){print(_+l);}}
value t=

"""shared void e(){
   value _="   ";value q="\"\"\"";
   void c(String s){for(l in s.lines.rest.exceptLast){print(_+l);}}
   value t=
   """;value b=
"""print(t);print(q+(t.lines.first else""));c(t);
   print(_+q+";value b=");
   print(q+(b.lines.first else""));c(b);print(_+q+";");print(b);
   }
   """;
print(t);print(q+(t.lines.first else""));c(t);
print(_+q+";value b=");
print(q+(b.lines.first else""));c(b);print(_+q+";");print(b);
}

Another, now "obvious" optimization would be to remove the line breaks (and most of the indentation) inside our long string literals here. By that, we actually only the first and last line of each to handle (first is to be printed with """, and the empty last one we print manually with the stuff behind it), and can get rid of the long c function which looped over everything but first and last line. This gets us down to 388:

shared void e(){value _="   ";value q="\"\"\"";value t=

"""shared void e(){value _="   ";value q="\"\"\"";value t=
   """;value b=
"""print(t);print(q+(t.lines.first else""));print(_+q+";value b=");print(q+(b.lines.first else""));print(_+q+";");print(b);}
   """;
print(t);print(q+(t.lines.first else""));print(_+q+";value b=");print(q+(b.lines.first else""));print(_+q+";");print(b);}

Now we can ask: why do we have many print statements, instead of using just one and some string concatenation? This gets rid of the remaining line breaks (and also the trailing empty line), and gets us down to 185 bytes (including the new line character at the end):

shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b="""print(t+q+t+q+";value b="+q+b+q+";"+b);}""";print(t+q+t+q+";value b="+q+b+q+";"+b);}

Here slightly easier to read (but without syntax highlighting):

shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b="""print(t+q+t+q+";value b="+q+b+q+";"+b);}""";print(t+q+t+q+";value b="+q+b+q+";"+b);}

We can actually remove another 9 characters by putting this single ; inside the b string:

shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b=""";print(t+q+t+q+";value b="+q+b+q+b);}""";print(t+q+t+q+";value b="+q+b+q+b);}

I don't see how this could be shrunk further anymore ... maybe with a totally different approach.

(I did put a commented version of this into my new Github repository).

As a bonus, an "ungolfed version" of the last one (463 chars):

shared void quine(){
    value quote = "\"\"\"";
    value top = """shared void quine(){#    value quote = "\"\"\"";#    value top = """;
    value bottom = """    print(top.replace("#","\n") + quote + top + quote + ";\n    value bottom = " + quote + bottom + quote + ";\n" + bottom.replace("$"+"$","\n"));$$}""";
    print(top.replace("#","\n") + quote + top + quote + ";\n    value bottom = " + quote + bottom + quote + ";\n" + bottom.replace("$"+"$","\n"));
}

This needed some additional tricks to encode the line breaks in each of the string literals, because once they should be printed directly, once not. In top, I use # as a replacement. In bottom, where I replace the # in top by a newline, we need to use a different replacement string. I chose the two letter-string $$, because that can be escaped by string concatenation.

Paŭlo Ebermann

Posted 2011-01-28T00:34:05.293

Reputation: 1 010

Dang! This is crazy! +1 – kirbyfan64sos – 2015-09-14T21:13:01.330

10

brainfuck, 392 bytes

Like this 755B answer, this quine is accompanied by an additional character, which appears in both source and output. I tested this using BFO in the windows terminal emulator ConEMU.

->++>+++>+>+>+++>>>>>>>>>>>>>>>>>>>>+>+>++>+++>++>>+++>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+>>+++>>+++>>>>>+++>+>>>>>>>>>++>+++>+++>+>>+++>>>+++>+>++>+++>>>+>+>++>+++>+>+>>+++>>>>>>>+>+>>>+>+>++>+++>+++>+>>+++>>>+++>+>++>+++>++>>+>+>++>+++>+>+>>+++>>>>>+++>+>>>>>++>+++>+++>+>>+++>>>+++>+>+++>+>>+++>>+++>>++[[>>+[>]++>++[<]<-]>+[>]<+<+++[<]<+]>+[>]++++>++[[<++++++++++++++++>-]<+++++++++.<]

Try it online!

The source and output have no linebreaks. The last character is a \x1a (SUB ctrl code).

Invented by Daniel B Cristofani.


How it works

Like many other brainfuck quines, this code first inputs a list of values that are later used to recreate the actual code, then it builds up a list that contains the "+" and ">" symbols needed for the input and then all characters are printed out.

Each character of the actual code (starting with +[) is stored in two cells. Let's call them x and y. The formula to calculate the current character is (x+2)*16 + (y+2) + 9, so the characters are encoded like this:

char ascii minus9 outX outY inX inY
+    43    34     2    2    0   0
-    45    36     2    4    0   2
.    46    37     2    5    0   3
<    60    51     3    3    1   1
>    62    53     3    5    1   3
[    91    82     5    2    3   0
]    93    84     5    4    3   2

All values are stored in reversed order. For example the starting ->++>+++>+>+>+++>> (2 3, 1 1, 3 0) encodes the .<] at the end of the code.

[tape: End Marker/EM(-1), [in values], Between Lists Marker(0), [out values]]

-                       set EM

                        read list of in values
[>++>+++>+>+>+++>>>>>>>>>>>.... ] 

                    build out values to generate list
+[                      while input (for each gt)

                    append pluses to out vals / always runs one extra time
  [                     while value gt 0 (for each plus)
    >>+                 copy in value to out value
    [>]++>++            append out values 2 2 (plus)
    [<]<-               decrement in value
  ]

  >+                    new out value 1 (for adding 2 to each in value / one by the extra loop and one by this)
  [>]<+<+++             add 3 and 1 to last out values (change plus to gt)
  [<]                   go to old in value
  <+                    repeat if not on EM
]

>+[>]++++>++            append out value 4 2 (minus)
                      >[instead of ">+", we could also use ">>", 
                        but a ">" is encoded as "+++>+>", while a "+" is encoded ">>", 
                        so it saves four bytes, when using "+>".]<

                    printing loop
[
  [<++++++++++++++++>-] add 16 times out value(X) to next out value(Y)
  <+++++++++            add constant 9
  .                     print char
  <                     go to next out value
]

The `` in the end appears, because the copy routine leaves the extra values 1, 1 at the end of the list, which will be encoded 16+1+9 = 25. If we wanted to avoid that, we had to replace the >+ by the code >>->. The input code of that section would change from >>+++>+> to +++>+>++>>+++>+>+++>+>, so the code would be 15 bytes longer.

mınxomaτ

Posted 2011-01-28T00:34:05.293

Reputation: 7 398

The output is ASCII-only and has 392 bytes. The last byte, \x1a, is rendered as a right arrow in code page 437; it's not the same as the unicode right arrow \u2192. – Mitch Schwartz – 2016-01-03T20:20:00.367

(Put another way, the 394-byte program ending with \xe2\x86\x92 is not a quine, but it prints the 392-byte quine ending with \x1a.) – Mitch Schwartz – 2016-01-03T20:38:56.747

2If you haven't written this yourself, I think it should be community wiki. – Martin Ender – 2016-01-04T15:29:40.473

10

JavaScript, 31 characters

function f(){alert(f+"f()")}f()

Is this seriously the shortest JavaScript quine here?

Kendall Frey

Posted 2011-01-28T00:34:05.293

Reputation: 2 384

75, without recursion: !function (x){alert('!'+x+'('+x+')')}(function (x){alert('!'+x+'('+x+')')}) – sdleihssirhc – 2014-10-27T05:12:08.103

10

HTML + CSS 118 78 77 75 53 51 50 characters

<style>*{display:flex}html:before{content:'<style>

This language isn't good for quining, but it works. Invalid HTML and CSS, but it doesn't really matter.

Konrad Borowski

Posted 2011-01-28T00:34:05.293

Reputation: 11 185

} isn't required – xem – 2013-12-21T19:02:13.023

1@xem: Removed '}. This abuses CSS error handling rules, but considering it's code golf, it's fine. – Konrad Borowski – 2013-12-21T19:13:32.600

What browser did this work in? Running in Chrome 59 and this outputs *{display:inline;font-family:monospace}style:before{content:'<style> – Patrick Roberts – 2017-07-16T05:25:18.220

Why does it need to be monospaced? And if it does, using <pre> is faster. – RamenChef – 2017-10-27T03:00:16.380

<style>*{display:inline}style:before{content:'<style> works for less bytes. – Rɪᴋᴇʀ – 2018-02-20T15:30:06.460

@Riker Not sure how I missed that. Fixed. – Konrad Borowski – 2018-02-21T12:17:01.647

display:flex seems to work as well. – Dennis – 2018-02-21T14:17:51.620

Cheat a bit, a blank file will serve the purpose. – Dennis C – 2018-07-23T15:16:08.413

10

Shakespeare Programming Language, 6060001 bytes

Disclaimer: I do not take credit for this, the generator was made by Florian Pommerening and Thomas Mayer.

An Epic Never-Ending Saga.

Paris, a stacky person.
Pinch, impersonates Paris.
Venus, the opposite of Paris and Pinch.
Puck, continuously speaking.
Ajax, constantly complaining.
Page, perpetually blabbing.
Ford, incessantly talking.
Viola, ceaselessly communicating.


            Act I: Prelude.

        Scene I: Best things last.

[Enter Venus and Paris]

Paris:
    Let us proceed to act V.



            Act II: Remembrance.

        Scene I: Forgetful Venus.

Paris:
    Remember nothing.
    [...]

Generator Link

Generated SPL Code

Translated C Code (requires spl.h and libspl.a from a bugfixed SPL version to compile)

Compiled binary

Oliver Ni

Posted 2011-01-28T00:34:05.293

Reputation: 9 650

This answer should be marked as community wiki, perhaps? – SuperJedi224 – 2016-12-10T23:12:15.900

@SuperJedi224 Done. Thank you. – Oliver Ni – 2016-12-11T04:37:05.227

@SuperJedi224 Community wiki is not a rep waiver.

– Dennis – 2016-12-16T04:45:46.077

Holy crap. ---- – MD XF – 2017-05-24T23:37:54.613

2also this is hardly golfed – Destructible Lemon – 2017-06-08T02:13:36.897

@user202729 Not according to the meta post I linked to. – Dennis – 2018-04-04T09:09:17.370

This was beaten. – user202729 – 2018-05-30T16:25:27.217

9

Mini-Flak, 6900 bytes

Mini-flak is a Turing complete subset of Brain-Flak. It works exactly like Brain-Flak except the [], <> and <...> operations are banned from use. Programming in Min-Flak is thus much more difficult than traditional Brain-Flak.

The main difficulty with Mini-Flak is the lack of random access. While Mini-flak is Turing complete, location of access (relative to the top of the stack) must be determined at compile time rather than run time.


The following is the quine. Unfortunately this quine has an order notation of O(7**n) (where n is its own length) and thus cannot be run to completion in the lifetime of the universe. I will hopefully convince you that it does work but for now you will have to trust me a bit. If you want a version that can be run in the lifetime of the universe (or an afternoon) you can scroll down a bit to my faster version.

(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(()()()())(()())(()()()()())(())(())(())(())(())(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(()()()())(()())(()())(()()()()())(()()()()()())(()())(()())(()()()()())(()()()()()())(()()()()())(()()()()()())(()()()()())(()()()()()())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(()()()())(()())(()()()()()())(()()()()())(()()()()()())(())(())(()()()()())(()()()()()())(()())(()()())(())(()()()()())(())(())(()()()()())(()()()()()())(()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(())(()()())(())(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()())(()()()()())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(())(()()()()())(()()()()()())(())(()())(()()())(())(()()()()())(()()()()()())(()())(()()()())(()())(()())(()()()()())(()()()()())(()()()()()())(())(()()())(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(())(())(()()()()())(()()()()()())(()()()()())(()()()()()())(()()())(())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(()()()()())(()()()()()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(())(())(())(()())(())(()())(())(()())(()())(()())(()()()()())(()()()()()())(()()()()())(()()()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(()()()()())(()()()()()())(())(()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(()()()()())(()()()()()())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()()()()())(()()()()()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(())(()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(())(()()()()())(()()()()()())(()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(())(()()())(())(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()())(()()()()())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(())(()()()()())(()()()()()())(())(()())(()()())(())(()()()()())(()()()()()())(()())(()()()())(()())(()())(()()()()())(()()()()())(()()()()()())(())(()()())(())(())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()()())(())(())(()()()()())(()()()()()())(()()())(())(()())(()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(())(())(()()()()())(()()()()()())(()()()()())(()()()()()())(()()())(())(()()()()())(()()()()()())(()())(()()()())(()()()()())(()()()()()())(())(()()()()())(()()()()()())(()())(()())(()()())(())(()()()()())(()()()()()())(()()())(()()()()())(()()()()()())(()()()())(()())(())(())(()()()()())(()()()()()())(()()())(())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(())(()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()())(())(()()()()())(()()()()()())(()()())(())(()())(())(())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(())(()())(()())(()()())(())(()())(()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()()()()())(()()()()()())(()())(()())(()()()())(()()()()())(()()()()()())(()())(()()()()()())(()()()()())(()()()()()())(({}({}))[({}[{}])]){((((((({}({}))[({}[{}])])){})){}{}{}{}({}))[({}[{}])])}{}(({})[({(({}[(((()()()){}()))]{})([((({}({}))[({}[{}])]))]{})){({}[()((({}()[({})])){{}([(({}({}[(({}[()]))]{})))]{})}{})]{})}(({}{}[({})]{}({}))[({}[{}])(({}[()(((((()()()()()){}){}){}))]{}){([(({}[()(({}()))]{}){([(({}[()((({}){}((()()())){}{}))]{}){([(({}[()(({}()()))]{}){([(({}[()(({}(((()()()()())){}{}){}))]{}){([({}({}()()))]{})}{})]{})}{})]{})}{})]{})}{})]{})}{})]{})}{})]{}){(({}[(((()()()){}()))]{})([((({}({}))[({}[{}])]))]{})){({}[()((({}()[({})])){{}([(({}({}[(({}[()]))]{})))]{})}{})]{})}(({}{}[({})]{}({}))[({}[{}])(({}[(((((()()()()()){}){}){}()))]{}){({}[()((((((()()()()()){}){}){}())[()]))]{})}{}((((()()()()()){}){}){}))]{})}{}

Explanation

Like my previous Brain-Flak quine This program has two parts. The first part pushes numbers between 1 and 6 to the stack representing the second part of the program using the following key.

1 -> (
2 -> )
3 -> [
4 -> ]
5 -> {
6 -> }

(Since there is no <> in Mini-Flak those characters are left unencoded). It does this in a deterministic fashion so that this section can be reversed by the next section.

The second section is a decoder. It takes the output from the first section and turns it into the code that generates that list and the code represented by that list (this section's source). However this is easier said than done. Because of Mini-Flak's lack of random access we are going to need to abandon Brain-Flak's traditional techniques in favor of some more bizarre methods. This program starts by compressing the entire stack into one base 7 number where each digit is one number in the list. It does that with the following code:

(({}({}))[({}[{}])]){(({}({}))[({}[{}])])((((({})){})){}{}{}{})(({}({}))[({}[{}])])}{}

Try it Online!

This is a pretty straightforward (as far as Mini-Flak goes) program and I won't get into how it works unless any one is interested. (It is a neat little program but to save space I will leave it out).

We now have one single number representing the entire program. I will push a copy to "temporary memory" (the scope) like follows:

(({})[(...)]{})

And decompose the original copy via repeated devision. Each time I remove a digit from the number I will convert it to the code that generates it.

Once I am done with that, the program will put the copy stored in temporary memory back down and begin a second decomposition. This time it will map each digit to the ASCII value of its corresponding brace as it is decomposed from the total.

Once that is done the program has constructed it's source so it simply terminates.


Verification

You might be suspicious of my program. How can we know that it actually works if it won't terminate in the lifetime of the universe?

So I have set up a "toy version" of the original quine to demonstrate that all of the parts are working.

Try it Online!

This version has the first part removed. You can pass the list of numbers that would be generated by the first part as command line arguments. It will construct code that pushes them and the code they represent. I provided a simple test case but I encourage you to try it out with your own! You will notice even with only six characters the run times are starting to become noticeably long. This is because the division I use is O(n). Slow division has always been a reality in Brain-Flak and it carries over into Mini-Flak.

If you have any questions or confusions comment them and I will be happy to address them.


106656 bytes

Now for my fast version.

This version takes about half an hour (175300470 Brain-Flak cycles) to run on my machine using the ruby interpreter. But for the best performance I suggest you use Crain-Flak the C interpreter which is much faster but lacks some of the polish of the ruby interpreter.

Try it online

Explanation

The reason that Miniflak quines are destined to be slow is Miniflak's lack of random access. In the short but slow version (short is a bit of an exaggeration and slow an understatement) I get around this by pushing all the numbers and then packaging them up into one number and unrolling it piece by piece. However this version does it quite differently. I create a block of code that takes in a number and returns a datum. Each datum represents a single character like before and the main code simply queries this block for each one at a time. This essentially works as a block of random access memory.


To construct this block I actually reused a method from my proof that Miniflak is Turing complete. For each datum there is a block of code that looks like this:

(({}[()])[(())]()){(([({}{})]{}))}{}{(([({}{}(%s))]{}))}{}

This subtracts one from the number on top of the stack and if zero pushes %s the datum beneath it. Since each piece decrements the size by one if you start with n on the stack you will get back the nth datum.

This is nice and modular, so it can be written by a program easily.


Next we have to set up the machine that actually translates this memory into the source. This consists of 5 parts as such:

([()]())(()()()())
{({}[(
   -
 )]{})
 1. (({}[()])[((()))]{}){(([({}{})]{}))}{}{([({}{}{}{}
     (((((((((((((((((((((((((((()()()()()){}){}){})((((()()()()){}){}())){}{})(((()()()()){}){}()){})[()()])[((((()()()()()){}){}){}()){}()])((((()()()()()){}){}){}()){}())[((((()()()()()){}){}){}()){}]))[()])())[()])())[()])())[()]))()))[()])((((()()()){}){}()){}){}())[((((()()()){}){}()){}){}])[()])((((()()()()){}){}())){}{})[((((()()()()){}){}())){}{}])
     (()()()())
    )]{})}{}
 2. (({}[()])[((()))]{}){(([({}{})]{}))}{}{([({}{}
     (({}(({}({}))[({}[{}])][(
     ({}[()(
      ([()](((()()[(((((((()()()){})())){}{}){}){})]((((()()()()())){}{}){})([{}]([()()](({})(([{}](()()([()()](((((({}){}){}())){}){}{}))))))))))))
     )]{})
     {({}[()(((({})())[()]))]{})}{}
     (([(((((()()()()){}){}()))){}{}([({})]((({})){}{}))]()()([()()]({}(({})([()]([({}())](({})([({}[()])]()(({})(([()](([({}()())]()({}([()](([((((((()()()())()){}){}){}()){})]({}()(([(((((({})){}){}())){}{})]({}([((((({}())){}){}){}()){}()](([()()])(()()({}(((((({}())())){}{}){}){}([((((({}))){}()){}){}]([((({}[()])){}{}){}]([()()](((((({}())){}{}){}){})(([{}](()()([()()](()()(((((()()()()()){}){}){}()){}()(([((((((()()()())){}){}())){}{})]({}([((((({})()){}){}){}()){}()](([()()])(()()({}(((((({}){}){}())){}){}{}(({})))))))))))))))))))))))))))))))))))))))))))))))
     )]{})[()]))({()([({})]{})}{}()()()())
    )]{})}{}
 3. (({}[()])[((()))]{}){(([({}{})]{}))}{}{([({}{}
      (({}[(
      ({}[()(((((()()()()()){}){}){}))]{}){({}[()(({}()))]{}){({}[()(({}((((()()()){}){}){}()){}))]{}){({}[()(({}()()))]{}){({}[()(({}(((()()()()())){}{}){}))]{}){([(({}{}()))]{})}}}}}{}
      (({}({}))[({}[{}])])
     )]{}({})[()]))
      ({()([({}({}[({})]))]{})}{}()()()()[(({}({})))]{})
    )]{})}{}
 4. (({}[()])[((()))]{}){(([({}{})]{}))}{}{([({}{}(([{}]))(()()()()))]{})}{}
    ({}[()])
}{}

The machine consists of four parts that are run in reverse starting with 4 and ending with 1. I have labeled them in the code above. Each section also uses the same lookup table format I use for the encoding. This is because the entire program is contained in a loop and we don't want to run every section every time we run through the loop so we put in the same RA structure and query the section we desire each time.

4

Section 4 is a simple set up section.

The program tells first queries section 4 and datum 0. Datum 0 does not exist so instead of returning that value it simply decrements the query once for each datum. This is useful because we can use the result to determine the number of data, which will become important in future sections. Section 4 records the number of data by negativizing the result and queries Section 3 and the last datum. The only problem is we cannot query section 3 directly. Since there is another decrement left we need to query a section 4. In fact this will be the case every time we query a section within another section. I will ignore this in my explanation however if you are looking a the code just remember 4 means go back a section and 5 means run the same section again.

3

Section 3 decodes the data into the characters that make up the code after the data block. Each time it expects the stack to appear as so:

Previous query
Result of query
Number of data
Junk we shouldn't touch...

It maps each possible result (a number from 1 to 6) to one of the six valid Miniflak characters ((){}[]) and places it below the number of data with the "Junk we shouldn't touch". This gets us a stack like:

Previous query
Number of data
Junk we shouldn't touch...

From here we need to either query the next datum or if we have queried them all move to section 2. Previous query is not actually the exact query sent out but rather the query minus the number of data in the block. This is because each datum decrements the query by one so the query comes out quite mangled. To generate the next query we add a copy of the number of data and subtract one. Now our stack looks like:

Next query
Number of data
Junk we shouldn't touch...

If our next query is zero we have read all the memory needed in section 3 so we add the number of data to the query again and slap a 4 on top of the stack to move onto section 2. If the next query is not zero we put a 5 on the stack to run section 3 again.

2

Section 2 makes the block of data by querying our RAM just as section 3 does.

For the sake of brevity I will omit most of the details of how section 2 works. It is almost identical to section 3 except instead of translating each datum into one character it translates each into a lengthy chunk of code representing its entry in the RAM. When section 2 is done it calls on section 1.

1

Section one is the most simple section.

It pushes the first bit of the quine ([()]())(()()()()){({}[( and defers to section 5.

5

There is no real section 5 instead a 5 will be decremented once by each section, entering none of them and the once more by the decrement hanging around at the end of the loop. This will result in a zero and will exit the main loop terminating the program.


I hope this was clear. Please comment if you are confused about anything.

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

2Wait... so the quine of a subset is shorter than the quine of the original? – ETHproductions – 2016-12-08T23:52:17.993

@ETHproductions No, the original was golfed down to 11k – James – 2016-12-09T00:14:28.447

@DJMcMayhem But isn't 6900 less than 11028? – ETHproductions – 2016-12-09T00:15:05.303

... Apparently I can't math... – James – 2016-12-09T00:16:34.893

9

JavaScript (ES6 REPL), 22 bytes

f=_=>"f="+f+";f()";f()

Idea stolen from Kendall Frey but in less bytes.

Since I cannot comment on his answer because I don't have rep I decided to make a new answer.

user64039

Posted 2011-01-28T00:34:05.293

Reputation:

2Welcome to the site! – James – 2017-01-02T17:56:21.867

1Save a byte with template literals: f=_=>'f=${f};f()';f() (replace single quotes with backticks). – Shaggy – 2017-04-26T16:11:08.200

(f=_=>*(f=${f})()*)() to save one byte (swap * with "`") – Brian H. – 2018-02-20T14:53:50.230

9

Forte, 66 bytes

Updated for the new Interpreter

2PUT34:LET1=3
4PUT34:END
1PRINT
"2PUT34:LET1=3
4PUT34:END
1PRINT
"

Which, in order is:

1: Print the first half of the code.
2: Print a ", then set line 3 to be line 1.
3: Print the second half of the code again.
4: Print another ", then end the program.

Try it online!

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

I remember when you and me were trying to do this. I am still impressed – Christopher – 2017-04-02T22:07:50.027

Why the bounty? – MD XF – 2017-05-24T23:38:31.613

@MDXF Bounty was for writing a Forte quine, which at the time, hadn't been done. – ATaco – 2017-05-24T23:50:41.277

@ATaco Ah, got it. Cheers – MD XF – 2017-05-24T23:51:22.997

9

Java 6 - 138 110 106

Since the question says "golf you a quine", I took Steve P's quine and golfed it:

enum Q{X;{String s="enum Q{X;{String s=%c%s%1$c;System.out.printf(s,34,s);}}";System.out.printf(s,34,s);}}

With credits to Trixie Wolf and Volune.
Note: you need to ignore stderr (e.g. 2>/dev/null)

For great good (and justice)!

aditsu quit because SE is EVIL

Posted 2011-01-28T00:34:05.293

Reputation: 22 326

I can't get this to work. Did you actually try to compile it? I think you need a System.exit() gimmick or it will fail to run properly. I'll add an answer here with my implementation later if I don't hear back from you soon. – Trixie Wolf – 2014-08-16T04:00:10.033

Actually: given the "ignore stderr" comment obv. you did get it to work. I'm very curious how, though. – Trixie Wolf – 2014-08-16T04:19:28.330

@TrixieWolf It works fine here, there is absolutely no compile error. Did you think I would post it without trying it first? :p Anyway, you can only run it with java 6 (or 5), newer versions check for the main method first. – aditsu quit because SE is EVIL – 2014-08-16T07:52:40.037

I'd like to suggest this improvement: enum Q{X;{String s="enum Q{X;{String s=%c%s%1$c;System.out.printf(s,34,s);}}";System.out.printf(s,34,s);}} – Volune – 2014-08-17T11:47:21.840

@aditsu Ah, that makes perfect sense. I'm busy today, but tomorrow I will check to see if mine still functions correctly (I tested it recently but I'll bet it was on J6). It might still work due to the exit() trick. – Trixie Wolf – 2014-08-17T21:35:33.183

@Volune That's my quine, Volune. :) Well, the one I've been asking about anyway (I am not the original source; found it years ago and adapted it). – Trixie Wolf – 2014-08-17T21:36:13.163

9

Klein, 11 + 6 = 17 bytes

3 additional bytes for the topology argument 001 and another 3 for ASCII output -A.

:?/:2+@> "

Try it online!

Let's start with the topology. The 1 at the end indicates that the north and south edges of the code are mapped to each other in reverse. So if the IP leaves the code through the south edge in the leftmost column, it will re-enter through the north edge in the rightmost column. We use this to skip to the end of the program.

:             Duplicate the top of the stack (implicitly zero).
?             Skip the next command if that value is non-zero (which it isn't).
/             Reflect the IP north.
              The IP leaves through the north edge in the third column from
              the left, so it will re-enter from the south edge in the third
              column from the right.
>             Move east.
":?/:2+@> "   Push the code points of the program, except for the quote itself
              to the stack.
:             Duplicate the top of the stack, now a 32 (the space).
?             Skip the next command (the /).
:             Duplicate the top of the stack again.
2+            Add 2, to turn the space into a quote.
@             Terminate the program.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

9

Befunge-93, 15 14 13 bytes

+9*5x:#,_:@#"

Works in this interpreter. x is an unrecognized command which reflects the instruction pointer.

Thanks to Jo King for saving 1 byte.

This 14 byte version works in FBBI:

+9*5<>:#,_:@#"

Try it online!

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

This almost works, but doesn't: "gx:#,_:@#/3: (also 13 bytes). – jimmy23013 – 2019-05-25T04:37:23.683

9

JavaScript REPL, 21 bytes

(_=$=>`(_=${_})()`)()

It technically doesn't read its own file.

… kind of seems like 0 is also a quine for JavaScript the way this is evaluated, though.

Ry-

Posted 2011-01-28T00:34:05.293

Reputation: 5 283

1Uncaught SyntaxError: Unexpected token => in Chrome – Nakilon – 2015-01-14T09:36:38.960

6@Nakilon: Use Firefox. – Ry- – 2015-01-14T16:17:49.293

2+1 for the +_+ in the shorter version – user48538 – 2016-01-04T18:31:10.833

2Umm... the first one is actually HTML5. – Erik the Outgolfer – 2016-06-15T08:07:23.900

10 is disallowed by our valid quine definition, which includes that some part of the program must encode a different part. – Ørjan Johansen – 2019-11-15T01:54:31.633

6It reads its own source, though. – Joey – 2011-05-12T21:15:22.640

9

PHP - 54 characters (no cheating)

<?printf($p='<?printf($p=%c%s%c,39,$p,39);',39,$p,39);

(finally even shorter)

Aurel Bílý

Posted 2011-01-28T00:34:05.293

Reputation: 1 083

9

MUMPS, 9 bytes

R w $T(R)

This may fall afoul of the "you can't just read the source file and print it" restriction. Let me explain why I say may.

The line of code you see above constitutes a complete MUMPS "routine" (named R), which is sort of like a single source file in a conventional C-like language... but not quite.

The way MUMPS stores its routines is peculiar among programming languages. Routines are not files living in a regular filesystem. Instead, they are data structures internal to the database itself. The line of code I've supplied above is actually stored as part of the MUMPS global named ^ROUTINE (globals are basically trees). The "R" subtree (in MUMPS parlance, "subscript") of that global would look something like this:

^ROUTINE("R",0)=1
^ROUTINE("R",1)="R w $T(R)"

The first entry is the number of lines of code in the routine. The subsequent entries are the lines of code in the routine itself.

Why do I bring this up? Well, this means that in MUMPS, the routines themselves are first-class entries in the database! One can edit routines by directly manipulating the contents of the ^ROUTINE global, just as one can edit any other global. (Indeed, at the most basic level, if your MUMPS environment doesn't come with an editor, you must invent one for yourself that will edit the ^ROUTINE global on your behalf.)

The ability to manipulate routines in MUMPS code is so important that the standard even defines a function whose explicit purpose is to tell you what code is found at a given line of a given routine. That function is named $T[EXT], and if you give it a pointer to a line of code, it will return the code present at that location.

And that's what we do here. We w[rite] the result of a call to $TEXT(R) - that is, the contents of the line at the first line of the routine R - to the output stream, and since R is only one line long, that makes the program a quine.

This program involves no file IO at all. The whole thing is internal to the MUMPS environment. I claim that this is interesting enough to count as a legitimate quine, despite the fact that this has a surface-level resemblance to a program that just reads and prints the source file.

senshin

Posted 2011-01-28T00:34:05.293

Reputation: 641

9

Japt, 10 bytes

"iQ ²"iQ ²

Here's how this works:

"iQ ²"      // Take this string.        iQ ²
      iQ    // Insert a quote.          "iQ ²
         ²  // Double.                  "iQ ²"iQ ²
            // Implicitly output.

Test it online!

Of course, any number literal is also a quine because of implicit output.

ETHproductions

Posted 2011-01-28T00:34:05.293

Reputation: 47 880

Does Japt add a newline at the end of implicit output? – CalculatorFeline – 2016-03-23T04:28:20.647

@CalculatorFeline Nope. – ETHproductions – 2016-09-07T02:24:12.887

9

Bash, 35 28 20 bytes

trap -- 'trap' EXIT

@Dennis pointed out that even the -p flag is not necessary, and trap will print the trap strings unqualified, which helped save another 8 bytes, and brought about another quine:

Zsh, 18 bytes

trap -- trap EXIT

Zsh trap does not print the single quotes, which makes it incompatible with the bash version, but also allows you to save another 2 bytes for the zsh-only version. Again, though, dash does not show this behavior and trap does not print anything.

Bash, 19 bytes

Another, just barely shorter, and much less interesting bash quine:

echo $BASH_COMMAND

Thankfully the lack of single quotes mean that in zsh, trap is still shorter, which is important because the $BASH_COMMAND variable does not exist. Additionally, I'd be tempted to count this as 'reading the source' but that might be because I like the trap one so much.

Bash 28 byte submission

trap -- 'trap -p EXIT' EXIT

Just realized that the echo statement could be cut out entirely, trap -p simply prints the trap statement in this format (saved another 7 bytes).

Compatibility: This must be in a script file, trap does not work as expected on the command line, and its bash-only: bourne shell/ash/dash does not support the -p flag to trap (obviously instrumental to the quine).

Original 35 byte submission:

trap -- 'echo `trap -p EXIT`' EXIT

A much farther golf of @ormaaj's trap-based solution. Shaves off 1 character by switching to backticks, 2 more because the quotes around the echo body are not necessary, and 9 characters by switching to echo. The real magic though, is switching from a DEBUG trap to EXIT. This saves 2 characters just because EXIT is shorter, and 3 more because you do not need to call : or print it (and it drastically simplified the escaping needed for echo).

I'm not 100% sure whether this counts as 34 or 35 bytes, as echo prints a trailing newline and I'm not sure whether its a true quine if I don't include a trailing newline in the source. I called it 35 bytes to be more safe/truthful, but I'd love to know what a real ruling on this is.

Link to @ormaaj's original solution. (If I had enough reputation to post these golfs as a comment on the original post, I would have. My apologies if any of this breaks convention.)

LinusKrom

Posted 2011-01-28T00:34:05.293

Reputation: 113

Welcome to Programming Puzzles & Code Golf, and congrats on a really neat quine! 1. trap -- 'trap' EXIT should work as well. 2. The trailing newline has to be counted, since the program wouldn't be a quine without it. 3. Your solution is different enough to be posted in a separate answer. No worries. – Dennis – 2016-10-17T20:24:55.947

What was the original answer? – CalculatorFeline – 2017-01-28T02:13:02.103

My original answer is the 35 byte one at the end of this post, with trap and echo. As I edited it and golfed my solution down farther, I added new solutions and comments to the top of the post. – LinusKrom – 2017-01-29T04:15:40.737

9

05AB1E, 14 bytes

Shortest proper 05AB1E quine?

0"D34çý"D34çý

With trailing newline.

Try it online!

Explanation:

0              # Push '0'
                   # Stack: ['0']
 "D34çý"       # Push 'D34çý'
                   # Stack: ['0', 'D34çý']
        D      # Duplicate
                   # Stack: ['0', 'D34çý', 'D34çý']
         34ç   # Push '"'
                   # Stack: ['0', 'D34çý', 'D34çý', '"']
            ý  # Join rest of the stack with '"'
                   # Stack: ['0"D34çý"D34çý']
               # Implicit print

Oliver Ni

Posted 2011-01-28T00:34:05.293

Reputation: 9 650

Isn't 1 also a proper quine? – ovs – 2017-01-15T19:24:47.430

2

@ovs Not by our standard definition.

– ETHproductions – 2017-01-25T16:37:32.623

8

RProgN, 3 bytes

0
0

Try it online!

This exploits a potential flaw in our definition of proper quine:

It must be possible to identify a section of the program which encodes a different part of the program. ("Different" meaning that the two parts appear in different positions.)

Furthermore, a quine must not access its own source, directly or indirectly.

The stack of RProgN is printed backwards, so the first 0 encodes the second 0, and vice versa.

This can be verified empirically; the program

1
2

prints

2
1

Try it online!

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

2Oh my, it's actually getting usage. I feel like a proud father. – ATaco – 2016-12-16T05:26:43.827

8

√ å ı ¥ ® Ï Ø ¿ , 9 (possibly 11) bytes

Non-competing as language post-dates the challenge

79 87  OW

Notice the double space between the 87 and the OW. This is necessary because of the way √ å ı ¥ ® Ï Ø ¿ outputs.

The O command outputs the whole of the stack as numbers

The W command outputs the whole stack as Unicode interpretations of the numbers

The 11 byte solution

The above code will output

===== OUTPUT =====

79 87  OW

==================

-----Program Execution Information-----

Code        : 79 87  OW
Inputs      : []
Stack       : (79,87)
G-Variable  : None
Byte Length : 9
Exit Status : 0
Error       : None

---------------------------------------

This is obviously not the code inputted but is outputted automatically by the interpreter. If this is disallowed, there is an 11 byte solution that only outputs the required output:

ł 79 87  OW

This will only output

ł 79 87  OW

I'm not sure if the 9 byte answer is acceptable, could someone please tell me in the comments?

caird coinheringaahing

Posted 2011-01-28T00:34:05.293

Reputation: 13 702

1This is a much less trivial quine than usual - nice! – isaacg – 2017-03-20T04:46:12.667

That looks valid (9 byte). I mean the other stuff is just interpreter items that are always there – Christopher – 2017-05-21T12:29:44.527

this isn't non-competing because this is a catalogue and any language is fine – Destructible Lemon – 2017-05-21T23:17:24.260

@DestructibleLemon I'm a stickler to explicit rules and it doesn't say that in the question. It's fine though. – caird coinheringaahing – 2017-05-22T06:10:58.390

Gesundheit! Wait... that's a language name? You didn't just sneeze bytes? How do you say that language name in a conversation haha! – Magic Octopus Urn – 2018-09-06T16:18:28.963

8

Reflections, 4222 bytes

Since wastl out-golfed me by about... 1.810371 bytes through a vastly superior encoding system, I've decided to have another look at the problem. Since my program is still quite long, here's the main section (with SOHs replaced with spaces):

\0=0#_(4:(2(4(40\
      /# 0v\/(1v/
      \+#@~ > ~<
/#@#_#_#_1^1/
+
\#1)(2:2)4=/

Try It Online! (but have patience) (ASCII-only points out that unchecking the time between steps will make it go faster, but beware of the javascript freezing up your browser)

This uses the same encoding as wastl's answer, where each character with byte value n is represented by n newlines followed by

+
#

and the first character of the code is \ to change the pointer's direction down. Additionally, it also encodes the \ as well as the #,+ and newline in this process to save on doing them later

The main code is a more streamlined version of wastl's, where quite a few shortcuts have been made. I've also replaced all the spaces with SOHs (byte value 1) to save on bytes.

Detailed explanation

\0=0        Create a copy of the data in stack 0
    #_      Print the `\`
      (4:(2(4(4   Push the +, \n, # to stack 4, and a copy of the newline to stack 2
               0\ Switch back to the intact copy of the data

            /(1v/ Reverse the data
            > ~<
          ^1/


          v\
          ~   While the stack exists
          ^

          v\

           1  Move data to stack 1

         4=/  Copy #, \n, +
    (2:2)     Copy newline
\#1)          Get top of data

+
\#        Redefine origin and move up

/
+     Push -2

/#@   Print the newline the value of the top of data times
   #_#_#_   Print the +, \n, #
         1^ Switch back to the data and loop again


      /# 0v When the data stack is empty
      \+#@~
/#@#_#_#_1^

         0  Switch to the other copy of the data

      /#    Redefine the origin to push 1
      \+
        #@  Print the whole stack
          ~ >  And end

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

You should also say that unchecking the time between steps box shortens run time to like <5 seconds – ASCII-only – 2018-05-22T00:58:39.307

@ASCII-only Ehh, depends on the computer I guess. Mine freezes up and finishes in about 40 seconds – Jo King – 2018-05-22T01:51:56.163

8

J (REPL) - 20 (16?) char

Seems we're missing a J entry. Trivially, any sentence that doesn't evaluate gets itself printed in the REPL, so 1 or + or +/ % # are all quines in that sense. A non-trivial quine would be one that produces specifically a string containing the source code.

',~@,~u:39',~@,~u:39

u:39 is the ASCII character 39, i.e. the single quote, and ',~@,~u:39' is a string. , is the append verb. The main verb ,~@,~ evaluates as follows:

x ,~@,~ y      
y ,~@, x       NB. x f~ y => y f x       "Passive"
,~ (y , x)     NB. x f@g y => f (x g y)  "At"
(y,x) , (y,x)  NB. f~ y => y f y         "Reflex"

So the result is 'string'string when x is string and y is the single quote, and thus this is a quine when x is ,~@,~u:39.

If we're allowed the J standard library as well, then we can write the 16 character

(,quote)'(,quote)'

which appends the quote of the string (,quote) to itself.

algorithmshark

Posted 2011-01-28T00:34:05.293

Reputation: 8 144

8

Shell echo-sed quine:

echo sed -eh -es/[\\\(\\\\\\\\\\\)\\\&\\\|]/\\\\\\\\\\\&/g -es/^/echo\\ / -es/$/\\\|/ -eG|
sed -eh -es/[\(\\\\\)\&\|]/\\\\\&/g -es/^/echo\ / -es/$/\|/ -eG

I wanted to write a sed quine, but sed can only work on its input stream, not generate output spontaneously, so this is an echo-sed quine. This 154-character quine uses command-line sed, which automatically makes it hard to read, and uses three different sed commands, as well as two sequences of eleven backslashes in a row. This quine works in bash, ksh, and sh, but not csh or tcsh.

EDIT:

A blatant, and amusing, cheat: echo $BASH_COMMAND

Another, unreasonably silly, cheat: export PROMPT_COMMAND='echo $BASH_COMMAND';$PROMPT_COMMAND

Andrew

Posted 2011-01-28T00:34:05.293

Reputation: 81

8

QBasic, 76 (110) 54 (72)

Tested with QB64 on Windows 7, with auto-formatting turned off.

READ a$:?a$;:WRITE a$:DATA"READ a$:?a$;:WRITE a$:DATA"

: is a statement separator, and ? is a shortcut for PRINT. The main trick here is using DATA and READ so we don't have to split the string up to add the quotes. Edit: I learned this week about the WRITE command, which outputs strings wrapped in double-quotes--a significant byte-saver here!

Since actual QBasic doesn't let you turn off auto-formatting, here's the same thing with proper formatting in 72 bytes:

READ x$: PRINT x$;: WRITE x$: DATA "READ x$: PRINT x$;: WRITE x$: DATA "

Original versions (76 bytes golfed, 110 formatted):

READ a$:q$=CHR$(34):?a$+q$+a$+q$:DATA"READ a$:q$=CHR$(34):?a$+q$+a$+q$:DATA"

or

READ a$: q$ = CHR$(34): PRINT a$ + q$ + a$ + q$: DATA "READ a$: q$ = CHR$(34): PRINT a$ + q$ + a$ + q$: DATA "

DLosc

Posted 2011-01-28T00:34:05.293

Reputation: 21 213

1Note that this doesn't work with QBasic 1.1 for MS-DOS 6.2: the autoformatter can't be turned off. – Mark – 2015-02-27T07:58:48.560

@Mark Good point. I added a formatted version. – DLosc – 2015-02-28T22:21:58.787

1You can just load the non-formatted file directly though, right? This seems like a limitation of the editor rather than the language itself. – 12Me21 – 2018-04-02T14:54:40.117

8

C, 77 chars

Maybe the easiest one in C.

main(){char*c="main(){char*c=%c%s%c;printf(c,34,c,34);}";printf(c,34,c,34);}

34 is the ASCII decimal for ".

efermat

Posted 2011-01-28T00:34:05.293

Reputation: 137

I count 76 bytes. – Lynn – 2017-01-18T15:06:57.490

@Lynn He must have used wc and forgot to exclude the trailing newline :P – MD XF – 2017-05-26T16:32:45.750

8

C, 78 chars

#define Q(S)char*q=#S;S
Q(main(){printf("#define Q(S)char*q=#S;S\nQ(%s)",q);})

This version is shorter than the familiar 79-character C quine and also doesn't assume ASCII. It does still assume that it's safe to not include stdio.h. (Adding an explicit declaration of printf() brings the length up to 103 chars.)

breadbox

Posted 2011-01-28T00:34:05.293

Reputation: 6 893

7

Charcoal, 64 31 32 (because of newlines)

My first answer in charcoal ever!

Similar to /// and other languages, just straight up ascii would print itself. however that is not payload and also boring, so here is an actual quine.

taking a golfing tip from Ascii-only, and my realisation that the second looping is pointless, I have reduced by >50%

A´α´´´A´F´α´⁺´´´´´ι´αα´AFα⁺´´ια

Try it online!

Explanation

(thanks to ascii-only for making most of this.)

A                     α            Assign to a
 ´α´´´A´F´α´⁺´´´´´ι´α             "α´AFα⁺´´ια", but with ´ escape character with each
                                    character
                                    these are the variable being assigned to, and the
                                    rest of the program that is not the string.

                        ´A         Print A to the grid. current grid: "A"
                           Fα⁺´´ι  For each character in a, print ´ + character
                                    this results in the escaped version of the string
                                    which is the literal string that is assigned at the 
                                    start. current grid state: "A´α´´´A´F´α´⁺´´´´´ι´α"

                                  α Print a ("α´AFα⁺´´ια"), which is the commands after
                                    the string assignment. final grid state vvv:
                                                 "A´α´´´A´F´α´⁺´´´´´ι´αα´AFα⁺´´ια"

[implicitly print the grid: "A´α´´´A´F´α´⁺´´´´´ι´αα´AFα⁺´´ια", the source, with a trailing newline]

Destructible Lemon

Posted 2011-01-28T00:34:05.293

Reputation: 5 908

Wish I was better at reading Charcoal. Looking forward to that explanation :) – Emigna – 2017-05-19T10:11:46.350

1I can hardly read this myself :P – Destructible Lemon – 2017-05-19T10:12:55.920

You can leave off the final closing double angle bracket, saving 3 bytes: A´α´´´A´F´L´α´«´´´´´§´α´ι´»´F´L´α´«´§´α´ια´AFLα«´´§αι»FL᫧αι – ASCII-only – 2017-05-19T10:33:55.217

Oh wait you can also iterate over the string directly. 37 bytes: A´α´´´A´F´α´⁺´´´´´ι´F´α´ια´AFα⁺´´ιFαι – ASCII-only – 2017-05-19T10:38:03.893

@ASCII-only couldn't this be one byte? f – Christopher – 2017-05-19T14:11:25.653

https://tio.run/nexus/charcoal#@5/2/z8A – Christopher – 2017-05-19T14:11:45.687

It is "A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output." – Christopher – 2017-05-19T14:12:09.013

@Christopher ... That way It isn't payload-capable so it actually isn't a quine (You can't have commands in the payload) – ASCII-only – 2017-05-20T00:02:07.313

@ASCII-only they defined their own quine definition so it does not need to be payload-capable. – Christopher – 2017-05-20T19:35:47.837

@Christopher Well if it's valid feel free to post a solution – ASCII-only – 2017-05-20T23:58:57.480

@Christopher That f suggestion seems to print an extra newline, so isn't a quine. But if it didn't, it would probably run afoul of the rule that there must be a part of the program that encodes a different part. – Ørjan Johansen – 2017-05-21T02:28:08.577

@ØrjanJohansen well adding a newline to the code works. But if it is not "encoding" what about the quine in golfscript? (1 and a newline) – Christopher – 2017-05-21T12:27:21.303

@Christopher Oh, when I tried adding a newline it seemed to get stuck, I didn't try waiting until TIO timed out though. If I recall correctly the argument for golfscript is that the newline is not encoding itself. – Ørjan Johansen – 2017-05-21T18:28:59.013

@ØrjanJohansen mine ran just fine. – Christopher – 2017-05-21T18:38:32.277

:( longer – ASCII-only – 2019-03-02T04:54:58.620

7

///, 204 bytes

/<\>/<\\\\>\\\\\\//P1/<>/<<>\><>/<<>\<>\<>\<>\><>\<>\<>\<>\<>\<>\<>/<>/P<>1<>/P<>2<>/<>/P<<>\<>\><>\<>\<>2<>/P<>1<>/<>/<<>\><>/<<<>\<>\>><>\<>\<>/<>/<<>\<>\><>/<>/P<>1//P<\\>\\2/P1//<\>/<<\\>>\\//<\\>//P1

Try it online!

With some helpful whitespace inserted:

/<\>/<\\\\>\\\\\\/
/P1/
    <>/<<>\><>/<<>\<>\<>\<>\><>\<>\<>\<>\<>\<>\<>/<>/P<>1<>/P<>2<>/<>/P<<>\<>\><>\<>\<>2<>/P<>1<>/<>/<<>\><>/<<<>\<>\>><>\<>\<>/<>/<<>\<>\><>/<>/P<>1
/
/P<\\>\\2/P1/
/<\>/<<\\>>\\/
/<\\>//
P1

How it works

  • The long third line is the quining data. It is made from the entire rest of the program, with a P2 in the spot where the data itself would fit, and then with the string <> inserted before each character from the set \/12.
    • It would be harmless to put <> before all characters in the data, but only these are necessary - \/ because they need escaping to be copied, and 12 because it's vital to have a break inside P1 and P2 to prevent infinite loops when substituting them.
  • The first substitution changes all the <> prefixes into <\\>\\\. The \ in the source <\> is there to prevent its final printable form from being garbled by the other substitutions.
  • The second substitution includes the quining data, copying them to the other P1s in the program. The <\\>\\\ prefixes now become <\>\ in both copies.
  • The third substitution copies one of the quining data copies (in the substitution itself) into the middle of the other (at the end of the program), marked by the string P<\>\2. In the inner copy, the <\>\ prefix now becomes <> again.
  • The fourth substitution changes the inner copy's <> prefixes into <<\>>\. The change is needed to introduce the final backspace, protecting any following \s and /s that are to be printed. The inner <\> is necessary to prevent this substitution from infinitely looping – just a backslash here wouldn't do, as it would be garbled by the fifth substitution.
  • The fifth substitution removes all instances of the string <\>, both those remaining in the outer copy of the quining data, and those produced by the fourth substitution.
  • Finally, we reach the constructed copy of the program, with suitable backslashes prepended to some characters, ready for printing.

Ørjan Johansen

Posted 2011-01-28T00:34:05.293

Reputation: 6 914

7

Brain-Flak, 1805 bytes

(())(()()()())(())(())(()()())(())(())(()()()())(())(())(()()()())(())(()()())(()())(()()())(())(()()()())(())(())(())(())(())(()())(()()()())(()())(()()())(())(()()()())(())(())(()()()())(())(()()())(()())(())(()()())(()()())(())(())(()()())(())(())(())(())(())(()()()())(())(())(()()())(())(())(())(()()())(()()())(()()()())(())(()()())(()())(())(()()())(())(())(())(())(())(()()())(()()()())(())(()())(())(()()())(()())(()()())(()()()())(())(()()())(())(())(())(())(()()())(()()()())(()())(())(()())(()()())(())(()())(()())(())(())(())(())(())(())(())(()())(())(()()())(())(())(()())(())(())(())(())(()()()())(()())(())(()()())(())(())(()()())(()())(())(()()())(()())(())(())(())(()())(())(())(()()())(()())(()())(()()()()())(()())(()())(()())(()()()())(())(())(()()())(())(())(()()())(()())(())(())(()()())(()())(()())(())(())(()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()()()())(())(()())(())(()()())(()())(()())(()()()())(()())(())(())(()())(()()()()())(()()())(())(()())(()())(())(())(())(()()())(())(())(()()()())(())(())(()()()())(())(()()())(()())(()()())(())(()()()())(())(())(()()()())(())(())(())(())(()())(()()()()())(())(())(()())(())(()()())(()())(()())(()())(())(()()()())(())(())(()())(())(()()())(()())(()()())(()()()())(())(()())(())(())(())(()()())(()()()()())(()())(()())(())(()()()())(())(())(())(()())(()()()()())(())(())(()())(())(()()())(())(())(()()())(())(())(()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()())(()())(())(()()()())(()()()){<>(((((()()()()()){}){}){}())[()])<>(([{}])()<{({}())<>((({}())[()]))<>}<>{({}<>)<>}{}>)((){[()](<(({}()<(((()()()()()){})(({})({}){})<((([(({})())]({}({}){}(<>)))()){}())>)>))((){()(<{}>)}{}<{({}()<{}>)}>{}({}<{{}}>{})<>)>)}{}){{}({}<>)<>{(<()>)}}<>{({}<>)<>}{}}<>

Try it online!

-188 bytes by avoiding code duplication

Like Wheat Wizard's answer, I encode every closing bracket as 1. The assignment of numbers to the four opening brackets is chosen to minimize the total length of the quine:

2: ( - 63 instances
3: { - 41 instances
4: < - 24 instances
5: [ -  5 instances

The other major improvement over the old version is a shorter way to create the code points for the various bracket types.

The decoder builds the entire quine on the second stack, from the middle outward. Closing brackets that have yet to be used are stored below a 0 on the second stack. Here is a full explanation of an earlier version of the decoder:

# For each number n from the encoder:
{

 # Push () on second stack (with the opening bracket on top)
 <>(((((()()()()()){}){}){}())[()])<>

 # Store -n for later
 (([{}])

  # n times
  {<({}())

    # Replace ( with (()
    <>((({}())[()]))<>

  >}{}

  # Add 1 to -n
  ())

  # If n was not 1:
  ((){[()]<

     # Add 1 to 1-n
     (({}())<

       # Using existing 40, push 0, 91, 60, 123, and 40 in that order on first stack
       <>(({})<(([(({})())]((()()()()()){})({}{}({})(<>)))({})()()())>)

     # Push 2-n again
     >)

     # Pop n-2 entries from stack
     {({}()<{}>)}{}

     # Get opening bracket and clear remaining generated brackets
     (({}<{{}}>{})

      (<

        # Add 1 if n was 2; add 2 otherwise
        # This gives us the closing bracket
        ({}(){()(<{}>)}

         # Move second stack (down to the 0) to first stack temporarily and remove the zero
         <<>{({}<>)<>}{}>

        # Push closing bracket
        )

      # Push 0
      >)

     # Push opening bracket
     )

     # Move values back to second stack
     <>{({}<>)<>}

   # Else (i.e., if n = 1):
   >}{})

 {

  # Create temporary zero on first stack
  (<{}>)

  # Move second stack over
  <>{({}<>)<>}

  # Move 0 down one spot
  # If this would put 0 at the very bottom, just remove it
  {}({}{(<()>)})

  # Move second stack values back
  <>{({}<>)<>}}{}

}

# Move to second stack for output
<>

Nitrodon

Posted 2011-01-28T00:34:05.293

Reputation: 9 181

It looks like you have a stray newline at the end of your code. You can save a byte by removing it. – 0 ' – 2017-12-28T18:55:44.147

5@0 ' Since Brain-Flak prints with a trailing newline. It is necessary for it to be a quine – H.PWiz – 2018-01-19T18:32:06.677

7

Reflections, 1.81x10375 bytes

Or to be more accurate, 1807915590203341844429305353197790696509566500122529684898152779329215808774024592945687846574319976372141486620602238832625691964826524660034959965005782214063519831844201877682465421716887160572269094496883424760144353885803319534697097696032244637060648462957246689017512125938853808231760363803562240582599050626092031434403199296384297989898483105306069435021718135129945 bytes.

The relevant section of code is:

+#::(1   \/  \    /: 5;;\
          >v\>:\/:4#+     +\
     /+#   /   2 /4):_    ~/
     \ _   2:#_/ \  _(5#\ v#_\
         *(2 \;1^    ;;4) :54/
         \/ \    1^X    \_/

Where each line is preceeded by 451978897550835461107326338299447674127391625030632421224538194832303952193506148236421961643579994093035371655150559708156422991206631165008739991251445553515879957961050469420616355429221790143067273624220856190036088471450829883674274424008061159265162115739311672254378031484713452057940090950890560145649762656523007858600799824096074497474620776326517358755429533782443 spaces. The amount of spaces is a base 128 encoded version of the second part, with 0 printing all the spaces again.

Edit: H.PWiz points out that the interpreter probably doesn't support this large an integer, so this is all theoretical

How It Works:

+#::(1  Pushes the addition of the x,y coordinates (this is the extremely large number)
        Dupe the number a couple of times and push one of the copies to stack 1
            \
             >
                   Pushes a space to stack 2
            *(2
            \/


             /  \
             >v >:\
        /+#   /   2   Print space number times
        \ _   2:#_/


                #      Pop the extra 0
                \;1^   Switch to stack 1 and start the loop


                   /:4#+      +\
                    /4):_     ~/    Divide the current number by 128
                    \  _(5#\ v      Mod a copy by 128
                   ^      4) :
                           \_/


                             v#_\  If the number is not 0:
                   ^    ;;4) :54/  Print the number and re-enter the loop

                     /: 5;;\
             v\      4             If the number is 0:
                     4             Pop the excess 0
              :            \       And terminate if the divided number is 0
                                   Otherwise return to the space printing loop
              \     1^X

Conclusion: Can be golfed pretty easily, but maybe looking for a better encoding algorithm would be best. Unfortunately, there's basically no way to push an arbitrarily large number without going to that coordinate.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

Does the interpreter support integers this large? – H.PWiz – 2018-03-25T00:42:37.343

@H.PWiz, erm, probably not. The interpreter is written in JS, which has a max integer size of 2^53-1 – Jo King – 2018-03-25T00:52:21.227

1Nevermind support for large integers. Where and how are you going to store the file? :P – Dennis – 2018-03-25T01:58:09.100

Please let me verify the solution first. I promise I will be done until April 1st. – wastl – 2018-03-25T16:01:16.193

Okay, you get the rep in 23 hours (when I can award the bounty). But I think you got the byte count wrong, I get about 1.8 * 10<s>375</s> for 4 lines of spaces. – wastl – 2018-03-31T10:58:43.120

Arg, looks like I got the formatting a bit wrong. I mean, 1.8e375 – wastl – 2018-04-01T08:42:28.690

2Now I really want to prove that this answer is highly suboptimal, but first I have to learn the language... – user202729 – 2018-04-01T13:52:24.353

@user202729 It's like ><>, but harder to work with. Read the wiki. – mbomb007 – 2018-05-02T14:16:00.057

@wastl You should make this page easier to find on the wiki, or include it somewhere. Also, it'd be nice if you fully explained your programs' steps (all of them) on the wiki, because the language isn't as intuitive as ><>.

– mbomb007 – 2018-05-02T14:17:02.117

@mbomb007 Added the link to the footer. Do you mean explain the examples? – wastl – 2018-05-02T14:31:21.823

@wastl Yeah, like you made it sound like you were explaining the Fibonacci program, then didn't really explain much of it. And you didn't explain the simple programs, like the one that clears the stack (I think it needs one, because I can't figure it out.) – mbomb007 – 2018-05-02T14:38:41.917

@mbomb007 Done

– wastl – 2018-05-02T17:02:36.913

@mbomb007 I've created a chat room for further discussion.

– wastl – 2018-05-03T07:11:10.553

1

Since V8 added support for BigInts, the interpreter integer limit should no longer be a problem - provided you can find a computer that can handle it.

– Nit – 2018-05-07T08:49:41.343

7

Brian & Chuck, 211 143 138 133 129 98 86 84 bytes

?.21@@/BC1@c/@/C1112BC1BB/@c22B2%C@!{<?
!.>.._{<+>>-?>.---?+<+_{<-?>+<<-.+?ÿ

Try it online!

old version:

?{<^?_>{_;?_,<_-+_;._;}_^-_;{_^?_z<_>>_->_->_*}_-<_^._=+_->_->_->_-!_	?_;}_^_}<?
!.>.>.>.+>._<.}+>.>.>?<{?_{<-_}<.<+.<-?<{??`?=

Try it online!

New code. Now the data isn't split into nul separated chunks, but the nul will be pulled through the data.

Brian:
?                   start Chuck

.21@@/BC1@c/@/C1112BC1BB/@c22B2%C@!
                    data. This is basically the end of the Brian code and the Chuck code reversed 
                    and incremented by four. This must be done because the interpreter tries
                    to run the data, so it must not contain runnable characters

                    ASCII 3 for marking the end of the code section
{<?                 loop the current code portion of Chuck

Chuck:
code 1 (print start of Brian code)
.>..               print the first 3 characters of Brian

code 2 (print the data section)
{<+>>-              increment char left to null and decrement symbol right to null
                    for the first char, this increments the question mark and decrements the
                    ASCII 1. So the question mark can be reused in the end of the Chuck code
?>.                 if it became nul then print the next character
---?+<+             if the character is ASCII 3, then the data section is printed.
                    set it 1, and set the next char to the left 1, too

code 3 (extract code from data)
{<-                 decrement the symbol left to the nul
?>+<<-.             if it became nul then it is the new code section marker, so set the old one 1
                    and print the next character to the left
+?                  if all data was processed, then the pointer can't go further to the left
                    so the char 255 is printed. If you add 1, it will be null and the code ends.
ÿ                   ASCII 255 that is printed when the end of the data is reached

Dorian

Posted 2011-01-28T00:34:05.293

Reputation: 1 521

7

TECO, 20 bytes

<Tab>V27:^TJDV<Esc>V27:^TJDV

The <Esc> should be replaced with ASCII 0x1B, and the <Tab> with 0x09.

  • <Tab>V27:^TJDV<Esc> inserts the text <Tab>V27:^TJDV. This is not because there is a text insertion mode which TECO starts in by default. Instead, <Tab> text <Esc> is a special insertion command which inserts a tab, and then the text. A string whose own initial delimiter is part of the text -- very handy.
  • V prints the current line.
  • 27:^T prints the character with ASCII code 27 without the usual conversion to a printable representation.
  • J jumps to the beginning of the text.
  • D deletes the first character (the tab).
  • V prints the line again.

feersum

Posted 2011-01-28T00:34:05.293

Reputation: 29 566

I gotta try this one out on TECOC :) https://github.com/blakemcbride/TECOC

– roblogic – 2019-09-25T17:24:06.163

7

T-SQL 24

This statment reproduces itself in the EVENTINFO column of the output:

dbcc inputbuffer(@@spid)

Explanation:

  • dbcc inputbuffer() - Displays the last statement sent from the client with the specified process id to the current instance of Microsoft SQL Server
  • @@spid - Retrieves the current process id

tested with SQL Server 2008 R2 and 2012; probably working with other versions as well

Online demo: http://www.sqlfiddle.com/#!3/d41d8/2230

Cristian Lupascu

Posted 2011-01-28T00:34:05.293

Reputation: 8 369

7

JavaScript (Firefox), 44 40 bytes

eval(e="alert('eval(e='+uneval(e)+')')")

Not sure how I haven't thought of this before; it's basically exactly the same as the standard function quine (f=_=>alert('f='+f+';f()'))(), but with a string. Funnily enough, I only thought of this while attempting to demonstrate how similar string-based quines are to function-based quines...

A cross-browser version (avoiding uneval) is 72 bytes:

Q='"';q="'";eval(e="alert('Q='+q+Q+q+';q='+Q+q+Q+';eval(e='+Q+e+Q+')')")

Or ES6, 50 bytes:

Q='"';eval(e="alert(`Q='${Q}';eval(e=${Q+e+Q})`)")

Previous answer, 74 bytes

".replace(/.+/,x=>alert(uneval(x)+x))".replace(/.+/,x=>alert(uneval(x)+x))

Simply takes the whole string and prepends its unevaluated form. Note: uneval may not work in all browsers. Here's a cross-browser version at 113 bytes:

".replace(/.+/,x=>alert(q+x+q+x.replace(/\\d/g,q)),q='1')".replace(/.+/,x=>alert(q+x+q+x.replace(/\d/g,q)),q='"')

Original answer, 118 bytes

Now, this certainly isn't a winner, but AFAIK, this is the first ever non-source-reading quine in JS! :D

alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))

How does it work, you ask? Well, if you look closely, you will see that it's really the same thing repeated twice:

alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))

The logic here is to A) place a copy of the real code in a string, and B) orient this string so the program can be split into two identical halves. But how could we get those quotes in there? Well, we could either navigate an insanely difficult path of inserting backslashes before a quote, or use the (painfully long) workaround String.fromCharCode(34) to retrieve one. The latter method is what I chose.

So, this code puts three copies of the string

,A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=

in an array, then joins them with quotes (using the mentioned workaround):

,A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=

and finally, slices off the unnecessary characters from the beginning and end:

,A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=
alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))alert([A=",A,A].join(String.fromCharCode(34)).slice(49,-9))

This leaves us with the text of the original program, which is alerted to the user.

If the alert is unnecessary, here's a 104-byte alternative:

[A=",A,A].join(String.fromCharCode(34)).slice(48,-3)[A=",A,A].join(String.fromCharCode(34)).slice(48,-3)

ETHproductions

Posted 2011-01-28T00:34:05.293

Reputation: 47 880

7

APL, 22 bytes

1⌽22⍴11⍴'''1⌽22⍴11⍴'''

This is part of the FinnAPL Idiom Library.

        '''1⌽22⍴11⍴'''  ⍝ The string literal '1⌽22⍴11⍴' (quotes in string)
     11⍴                ⍝ Fill an 11-element array with these characters
                        ⍝ But the string has length 10, so we get '1⌽22⍴11⍴''
  22⍴                   ⍝ Do this again for 22 chars: '1⌽22⍴11⍴'''1⌽22⍴11⍴''
1⌽                      ⍝ Rotate left (puts quote at the back)

Try it on ngn/apl

Alex A.

Posted 2011-01-28T00:34:05.293

Reputation: 23 761

7

Factor - 74 69 65 bytes

Works on the listener (REPL):

USE: formatting [ "USE: formatting %u dup call" printf ] dup call

This is my first ever quine, I'm sure there must be a shorter one! Already shorter. Now I'm no longer sure... (bad pun attempt)

What it does is:

  • USE: formatting import the formatting vocabulary to use printf
  • [ "U... printf ] create a quotation (or lambda, or block) on the top of the stack
  • dup call duplicate it, and call it

The quotation takes the top of the stack and embeds it into the string as a literal.

Thanks, cat! -> shaved 2 4 more bytes :D

fede s.

Posted 2011-01-28T00:34:05.293

Reputation: 945

1

Welcome to the site. This is a really good answer; however most people replace their old code with the new code and use the edit history to see the old code. You have, however, included a code breakdown and explanation, which not many people do on their first answer, so for that: +1.

– wizzwizz4 – 2016-02-14T09:03:07.900

@wizzwizz4 Thanks for the advice and up! Actually my 2nd answer, but first quine ever and first edit on PCG. – fede s. – 2016-02-14T22:07:11.590

Well, if you ever need help, feel free to ping me. – wizzwizz4 – 2016-02-14T22:11:22.557

I never realised a quine was so simple in Factor! Also, the bottom, shorter one can be a single line for 65 bytes, because you don't need the trailing newline: USE: formatting [ "USE: formatting %u dup call" printf ] dup call – cat – 2016-05-17T22:55:22.420

Thanks, @cat Just assumed it expected EOL, but this makes more sense actually! – fede s. – 2016-05-17T23:07:57.073

@fedes. No problem c: you don't need the \n at the end of the format string, also – cat – 2016-05-17T23:09:17.497

@cat that happens when you try to read faster than you can think :/ added that. Too bad your trick of skipping ws after strings doesn't work here. pretty-printer adds the space by itself, so it's no longer a quine. (Same prob. with Smalltalk) – fede s. – 2016-05-17T23:24:42.880

@fedes. Hm, interesting, I think this is as short as it can go – cat – 2016-05-17T23:29:33.607

7

RETURN, 18 bytes

"34¤¤,,,,"34¤¤,,,,

Try it here.

First RETURN program on PPCG ever! RETURN is a language that tries to improve DUP by using nested stacks.

Explanation

"34¤¤,,,,"         Push this string to the stack
          34       Push charcode of " to the stack
            ¤¤     Duplicate top 2 items
              ,,,, Output all 4 stack items from top to bottom

Mama Fun Roll

Posted 2011-01-28T00:34:05.293

Reputation: 7 234

7

S.I.L.O.S, 3057 bytes

A = 99
def S set 
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 76
A + 1
S A 105
A + 1
S A 110
A + 1
S A 101
A + 1
S A 32
A + 1
S A 65
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 57
A + 1
S A 57
A + 1
S A 10
A + 1
S A 72
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 56
A + 1
S A 51
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 32
A + 1
S A 100
A + 1
S A 101
A + 1
S A 102
A + 1
S A 32
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 67
A + 1
S A 104
A + 1
S A 97
A + 1
S A 114
A + 1
S A 32
A + 1
S A 72
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 76
A + 1
S A 105
A + 1
S A 110
A + 1
S A 101
A + 1
S A 32
A + 1
S A 32
A + 1
S A 83
A + 1
S A 32
A + 1
S A 10
A + 1
S A 67
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 57
A + 1
S A 57
A + 1
S A 10
A + 1
S A 66
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 103
A + 1
S A 101
A + 1
S A 116
A + 1
S A 32
A + 1
S A 67
A + 1
S A 10
A + 1
S A 108
A + 1
S A 98
A + 1
S A 108
A + 1
S A 68
A + 1
S A 10
A + 1
S A 67
A + 1
S A 32
A + 1
S A 43
A + 1
S A 32
A + 1
S A 49
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 67
A + 1
S A 104
A + 1
S A 97
A + 1
S A 114
A + 1
S A 32
A + 1
S A 72
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 32
A + 1
S A 32
A + 1
S A 65
A + 1
S A 32
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 73
A + 1
S A 110
A + 1
S A 116
A + 1
S A 32
A + 1
S A 66
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 76
A + 1
S A 105
A + 1
S A 110
A + 1
S A 101
A + 1
S A 32
A + 1
S A 65
A + 1
S A 32
A + 1
S A 43
A + 1
S A 32
A + 1
S A 49
A + 1
S A 10
A + 1
S A 66
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 103
A + 1
S A 101
A + 1
S A 116
A + 1
S A 32
A + 1
S A 67
A + 1
S A 10
A + 1
S A 105
A + 1
S A 102
A + 1
S A 32
A + 1
S A 66
A + 1
S A 32
A + 1
S A 68
A + 1
S A 10
A + 1
S A 70
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 57
A + 1
S A 57
A + 1
S A 10
A + 1
S A 69
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 103
A + 1
S A 101
A + 1
S A 116
A + 1
S A 32
A + 1
S A 70
A + 1
S A 10
A + 1
S A 108
A + 1
S A 98
A + 1
S A 108
A + 1
S A 71
A + 1
S A 10
A + 1
S A 70
A + 1
S A 32
A + 1
S A 43
A + 1
S A 32
A + 1
S A 49
A + 1
S A 10
A + 1
S A 112
A + 1
S A 114
A + 1
S A 105
A + 1
S A 110
A + 1
S A 116
A + 1
S A 67
A + 1
S A 104
A + 1
S A 97
A + 1
S A 114
A + 1
S A 32
A + 1
S A 69
A + 1
S A 10
A + 1
S A 69
A + 1
S A 32
A + 1
S A 61
A + 1
S A 32
A + 1
S A 103
A + 1
S A 101
A + 1
S A 116
A + 1
S A 32
A + 1
S A 70
A + 1
S A 10
A + 1
S A 105
A + 1
S A 102
A + 1
S A 32
A + 1
S A 69
A + 1
S A 32
A + 1
S A 71
A + 1
printLine A = 99
H = 83
print def 
printChar H
printLine  S 
C = 99
B = get C
lblD
C + 1
printChar H
print  A 
printInt B
printLine A + 1
B = get C
if B D
F = 99
E = get F
lblG
F + 1
printChar E
E = get F
if E G

Try it online!

I am ashamed to say this took me a while to write even though most of it was generated by another java program. Thanks to @MartinEnder for helping me out. This is the first quine I have ever written. Credits go to Leaky Nun for most of the code. I "borrowed his code" which was originally inspired by mine. My answer is similar to his, except it shows the "power" of the preprocessor. Hopefully this approach can be used to golf of bytes if done correctly. The goal was to prevent rewriting the word "set" 100's of times.
Please check out his much shorter answer!

Rohan Jhunjhunwala

Posted 2011-01-28T00:34:05.293

Reputation: 2 569

How does this work? – Leaky Nun – 2016-08-26T18:44:27.637

It's borked from my understanding @LeakyNun but it essentially writes it source code to the memory buffer, and then prints out commands to write itself to the memory buffer, and then writes itself out – Rohan Jhunjhunwala – 2016-08-26T18:46:11.093

From my point of view this is not a quine? – Leaky Nun – 2016-08-26T18:55:58.237

@LeakyNun it's borked... let me fix... should I delete, fix and undelete? – Rohan Jhunjhunwala – 2016-08-26T18:58:47.053

7

F#, 90 bytes

let q="let q=%A
printf(Printf.TextWriterFormat<_>q)q"
printf(Printf.TextWriterFormat<_>q)q

F#’s smart printf comes back to byte us! We can’t write let q="...";;printf q q, as the first parameter to printf isn’t actually a string:

printf : TextWriterFormat<'T> -> 'T

F# uses some compiler magic under the hood to guarantee type-safe printf calls. For example, "yay %d wow!" is a valid TextWriterFormat<int -> unit> literal, but not a valid TextWriterFormat<double -> unit> literal. But if we define the format string separately, the compiler will see it as a regular old string and complain. Instead, we have to convert q ourselves in the first argument.

What about let q:TextWriterFormat<_>="..."? First of all, that’s two bytes longer. But second of all, the second argument to printf really needs to be a string, otherwise the typechecker will infer that we’re formatting a formatter, which in turn formats a formatter, which formats a…

error FS0001: Type mismatch. Expecting a
    'a    
but given a
    Printf.TextWriterFormat<('a -> unit)>    
The resulting type would be infinite when unifying ''a' and
    'Printf.TextWriterFormat<('a -> unit)>'

Yep, an infinite type. Oops.

Lynn

Posted 2011-01-28T00:34:05.293

Reputation: 55 648

+1 for emoticon in the code <_> – user48538 – 2016-08-03T18:32:49.233

7

S.I.L.O.S, 2642 2593 bytes

Credits to Rohan Jhunjhunwala for the algorithm.

A = 99
set A 112
A + 1
set A 114
A + 1
set A 105
A + 1
set A 110
A + 1
set A 116
A + 1
set A 76
A + 1
set A 105
A + 1
set A 110
A + 1
set A 101
A + 1
set A 32
A + 1
set A 65
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 57
A + 1
set A 57
A + 1
set A 10
A + 1
set A 67
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 57
A + 1
set A 57
A + 1
set A 10
A + 1
set A 66
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 103
A + 1
set A 101
A + 1
set A 116
A + 1
set A 32
A + 1
set A 67
A + 1
set A 10
A + 1
set A 108
A + 1
set A 98
A + 1
set A 108
A + 1
set A 68
A + 1
set A 10
A + 1
set A 67
A + 1
set A 32
A + 1
set A 43
A + 1
set A 32
A + 1
set A 49
A + 1
set A 10
A + 1
set A 112
A + 1
set A 114
A + 1
set A 105
A + 1
set A 110
A + 1
set A 116
A + 1
set A 32
A + 1
set A 115
A + 1
set A 101
A + 1
set A 116
A + 1
set A 32
A + 1
set A 65
A + 1
set A 32
A + 1
set A 10
A + 1
set A 112
A + 1
set A 114
A + 1
set A 105
A + 1
set A 110
A + 1
set A 116
A + 1
set A 73
A + 1
set A 110
A + 1
set A 116
A + 1
set A 32
A + 1
set A 66
A + 1
set A 10
A + 1
set A 112
A + 1
set A 114
A + 1
set A 105
A + 1
set A 110
A + 1
set A 116
A + 1
set A 76
A + 1
set A 105
A + 1
set A 110
A + 1
set A 101
A + 1
set A 32
A + 1
set A 65
A + 1
set A 32
A + 1
set A 43
A + 1
set A 32
A + 1
set A 49
A + 1
set A 10
A + 1
set A 66
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 103
A + 1
set A 101
A + 1
set A 116
A + 1
set A 32
A + 1
set A 67
A + 1
set A 10
A + 1
set A 105
A + 1
set A 102
A + 1
set A 32
A + 1
set A 66
A + 1
set A 32
A + 1
set A 68
A + 1
set A 10
A + 1
set A 70
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 57
A + 1
set A 57
A + 1
set A 10
A + 1
set A 69
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 103
A + 1
set A 101
A + 1
set A 116
A + 1
set A 32
A + 1
set A 70
A + 1
set A 10
A + 1
set A 108
A + 1
set A 98
A + 1
set A 108
A + 1
set A 71
A + 1
set A 10
A + 1
set A 70
A + 1
set A 32
A + 1
set A 43
A + 1
set A 32
A + 1
set A 49
A + 1
set A 10
A + 1
set A 112
A + 1
set A 114
A + 1
set A 105
A + 1
set A 110
A + 1
set A 116
A + 1
set A 67
A + 1
set A 104
A + 1
set A 97
A + 1
set A 114
A + 1
set A 32
A + 1
set A 69
A + 1
set A 10
A + 1
set A 69
A + 1
set A 32
A + 1
set A 61
A + 1
set A 32
A + 1
set A 103
A + 1
set A 101
A + 1
set A 116
A + 1
set A 32
A + 1
set A 70
A + 1
set A 10
A + 1
set A 105
A + 1
set A 102
A + 1
set A 32
A + 1
set A 69
A + 1
set A 32
A + 1
set A 71
A + 1
printLine A = 99
C = 99
B = get C
lblD
C + 1
print set A 
printInt B
printLine A + 1
B = get C
if B D
F = 99
E = get F
lblG
F + 1
printChar E
E = get F
if E G

Try it online!

Leaky Nun

Posted 2011-01-28T00:34:05.293

Reputation: 45 011

Good job! May I "borrow this post for my github repository? – Rohan Jhunjhunwala – 2016-08-26T19:12:34.010

@RohanJhunjhunwala Sure. – Leaky Nun – 2016-08-26T19:18:44.527

6

Husk, 8 bytes

S+s"S+s"

Try it online!

Husk is a new golfing functional language created by me and Zgarb. It is based on Haskell, but has an intelligent inferencer that can "guess" the intended meaning of functions used in a program based on their possible types.

Explanation

This is a quite simple program, composed by just three functions:

S is the S combinator from SKI (typed) combinator calculus: it takes two functions and a third value as arguments and applies the first function to the value and to the second function applied to that value (in code: S f g x = f x (g x)).

This gives us +"S+s"(s"S+s"). s stands for show, the Haskell function to convert something to a string: if show is applied to a string, special characters in the string are escaped and the whole string is wrapped in quotes.

We get then +"S+s""\"S+s\"". Here, + is string concatenation; it could also be numeric addition, but types wouldn't match so the other meaning is chosen by the inferencer.

Our result is then "S+s\"S+s\"", which is a string that gets printed simply as S+s"S+s".

Leo

Posted 2011-01-28T00:34:05.293

Reputation: 8 482

6

C (gcc), 78 70 66 62 bytes

Minus 4 bytes thanks to MD XF (reusing first argument of printf)!

There are a few unprintables in this answer, replaced with ?.

main(){printf("main(){printf(%c%s%1$c,34,'@??');}",34,'@??');}

Here's an xxd:

00000000: 6d61 696e 2829 7b70 7269 6e74 6628 226d  main(){printf("m
00000010: 6169 6e28 297b 7072 696e 7466 2825 6325  ain(){printf(%c%
00000020: 7325 3124 632c 3334 2c27 4005 9027 293b  s%1$c,34,'@..');
00000030: 7d22 2c33 342c 2740 0590 2729 3b7d       }",34,'@..');}

Here's a bash script to generate and execute the program.

62 bytes, part 2

Here's a version that I have tested on my windows machine on gcc (ANSI encoded):

main(){printf("main(){printf(%c%s%1$c,34,'@@0');}",34,'@@0');}

Here's the output:

C:\Users\Conor O'Brien\Documents
λ xxd test.c
00000000: 6d61 696e 2829 7b70 7269 6e74 6628 226d  main(){printf("m
00000010: 6169 6e28 297b 7072 696e 7466 2825 6325  ain(){printf(%c%
00000020: 7325 3124 632c 3334 2c27 4040 3027 293b  s%1$c,34,'@@0');
00000030: 7d22 2c33 342c 2740 4030 2729 3b7d       }",34,'@@0');}

C:\Users\Conor O'Brien\Documents
λ cat test.c
main(){printf("main(){printf(%c%s%1$c,34,'@@0');}",34,'@@0');}
C:\Users\Conor O'Brien\Documents
λ wc test.c -c
62 test.c

C:\Users\Conor O'Brien\Documents
λ gcc test.c -o test
test.c:1:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main(){printf("main(){printf(%c%s%1$c,34,'@@0');}",34,'@@0');}
 ^
test.c: In function 'main':
test.c:1:8: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
 main(){printf("main(){printf(%c%s%1$c,34,'@@0');}",34,'@@0');}
        ^
test.c:1:8: warning: incompatible implicit declaration of built-in function 'printf'
test.c:1:8: note: include '<stdio.h>' or provide a declaration of 'printf'
test.c:1:55: warning: multi-character character constant [-Wmultichar]
 main(){printf("main(){printf(%c%s%1$c,34,'@@0');}",34,'@@0');}
                                                       ^

C:\Users\Conor O'Brien\Documents
λ test
main(){printf("main(){printf(%c%s%1$c,34,'@@0');}$c,34,'@@0');}
C:\Users\Conor O'Brien\Documents
λ

66 bytes

main(){printf("main(){printf(%c%s%1$c,34,4195728);}",34,4195728);}

I have no idea why this works, 100% honest here. But dang, is it short. Only 6 bytes longer than the current best.

Try it online!

70 bytes

main(){printf("main(){printf(%c%s%c,34,4195728,34);}",34,4195728,34);}

Try it online!

78 bytes

main(){printf("main(){printf(%c%s%c,34,%c%c+8,34,34,34);}",34,""+8,34,34,34);}

Try it online!

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

66 bytes – MD XF – 2017-07-25T04:46:44.550

It works because printf is very weakly typed, so your integer constant gets interpreted as the actual pointer address of the format string constant. Very implementation-dependent, I tried it on a different Linux machine and even there I needed to adjust the numbers. – Ørjan Johansen – 2017-07-25T06:21:52.050

@ØrjanJohansen Thanks, I figured it had something to do with addressing. – Conor O'Brien – 2017-07-25T16:39:57.207

Aha, you found out how to get it down to 62 non-locally! – MD XF – 2017-07-25T17:03:24.393

@MDXF Yes I did :> – Conor O'Brien – 2017-07-25T17:15:21.840

@ConorO'Brien Also, 63 bytes without using wide-char magic

– MD XF – 2017-07-25T17:28:39.647

6

Implicit, 20 bytes

«@171%@187»@171%@187

This didn't work in older versions of Implicit.

Try it online!

How it works

«@171%@187»           Push the string '@171%@187' on the stack. Let's call it s.
           @171       Print '«' (char code 171), without pushing it on the stack.
               %      Print s without popping it from the stack.
                @187  Print '»' (char code 171), without pushing it on the stack.
                      (implicit) Print the top of the stack: s.

Implicit, 26 bytes

«:171,::187,"»:171,::187,"

Try it online!

How it works

«:171,::187,"»              Push the string ':171,::187,"' on the stack.
                            Let's call it s.
              :171          Push 171 (code point of «).
                  ,         Swap s and 171.
                   :        Push a copy of s.
                    :187    Push 187 (code point of »).
                        ,   Swap the copy of s and ».
                         "  Combine the entire stack into a string.

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

1+1, got the same solution not long after. – ATaco – 2017-09-22T02:31:36.350

6

Bash, 48 bytes

Q=\';q='echo "Q=\\$Q;q=$Q$q$Q;eval \$q"';eval $q

Try it online!

Dom Hastings

Posted 2011-01-28T00:34:05.293

Reputation: 16 415

1Hm the leaderboard gives a shorter one, although that one uses sed while you are only using builtins. – Ørjan Johansen – 2018-02-07T17:14:14.463

After a search, I think this is currently the shortest with only builtins and a "normal" quine construction. – Ørjan Johansen – 2018-02-07T17:28:39.610

Thanks for taking a look @ØrjanJohansen! I'd like to differentiate this from the other solutions, but I don't know if I should change this title or the ones that use core utils... I'm happy with just coming up with the program to be honest! – Dom Hastings – 2018-02-07T19:22:53.660

Bash + coreutils seems to be fairly common, so I'd suggest to edit the header of the other answer. – Laikoni – 2018-02-10T12:07:26.533

6

Befunge 98 - 17 11 characters

<@,+1!',k9"

Or if using g is allowed:

Befunge 98 - 12 10

<@,g09,k8"

Justin

Posted 2011-01-28T00:34:05.293

Reputation: 19 757

Explanation for why using g may not be allowed? – MD XF – 2017-06-09T23:56:27.500

@MDXF g is arguably reading the source code. Befunge copies the code to the execution space and g reads the character at the x, y position in the execution space – Justin – 2017-06-11T06:50:08.673

6

Alchemist, 720 657 637 589 bytes

-68 bytes thanks to Nitrodon!

0n0n->1032277495984410008473317482709082716834303381684254553200866249636990941488983666019900274253616457803823281618684411320510311142825913359041514338427283749993903272329405501755383456706244811330910671378512874952277131061822871205085764018650085866697830216n4+Out_"0n0n->"+Out_n4+nn+n0n
4n0+4n0+n->Out_"n"
n+n+4n0+n0+n0+n0->Out_"+"
n+n+n+4n0+n0+n0->Out_n
4n+4n0+n0->Out_"4"
4n+n+4n0->Out_"\""
4n+n+n+n0+n0+n0->Out_"->"
4n+n+n+n+n0+n0->Out_"\n"
4n+4n+n0->Out_"Out_"
4n+4n+n->Out_"\\"
nn->4n0+4n0+nnn
n0+n4->n
nnn+4n+4n+n4->nn+n00
nnn+0n4->n+n40
n40+0n00+n4->n4+nn
n40+0n+n00->n4+n40

Try it online!

Warning, takes far longer than the lifetime of the universe to execute, mostly cause we have to transfer that rather large number on the first line back and forth between multiple atoms repeatedly. Here's a version that outputs the first few lines in a reasonable amount of time.

Here is the encoder that turns the program into the data section

Everything but the large number on the first line is encoded using these 8 9 tokens:

0 n + -> " \n Out_ \ 4

That's why all the atom names are composed of just n,0 and 4.

As a bonus, this is now fully deterministic in what order the rules are executed.

Explanation:

Initialise the program
0n0n->        If no n0n atom (note we can't use _-> since _ isn't a token)
      n4+Out_"0n0n->"+Out_n4+nn4+n0n
      NUMn4           Create a really large number of n4 atoms  
      +Out_"0n0n->"   Print the leading "0n0n->"
      +Out_n4         Print the really large number
      +nn             Set the nn flag to start getting the next character
      +n0n            And prevent this rule from being called again


Divmod the number by 9 (nn and nnn flag)
nn->4n0+4n0+nnn          Convert the nn flag to 8 n0 atoms and the nnn flag
n0+n4->n                 Convert n4+n0 atoms to an n atom
nnn+4n+4n+n4->nn+n00     When we're out of n0 atoms, move back to the nn flag
                         And increment the number of n00 atoms
nnn+0n4->n+n40           When we're out of n4 atoms, add another n atom and set the n40 flag


Convert the 9 possible states of the n0 and n atoms to a token and output it (nn flag)
n+4n0+4n0->Out_"n"           1n+8n0 -> 'n'
n+n+4n0+n0+n0+n0->Out_"+"    2n+7n0 -> '+'
n+n+n+4n0+n0+n0->Out_n       3n+6n0 -> '0'
4n+4n0+n0->Out_"4"           4n+5n0 -> '4'
4n+n+4n0->Out_"\""           5n+4n0 -> '"'
4n+n+n+n0+n0+n0->Out_"->"    6n+3n0 -> '->'
4n+n+n+n+n0+n0->Out_"\n"     7n+2n0 -> '\n'
4n+4n+n0->Out_"Out_"         8n+1n0 -> 'Out_'
4n+4n+n->Out_"\\"            9n+0n0 -> '\'

Reset (n40 flag)
n40+0nn+n00->n4+n40    Convert all the n00 atoms back to n4 atoms
n40+0n00+n4->n4+nn     Once we're out of n00 atoms set the nn flag to start the divmod

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

n0 and n4 should never exist at the same time without nnn, so the explicit catalyst is unnecessary in the twelfth line. Also, the literal "0" can be replaced by n (which you have 0 of), though this is version dependent. – Nitrodon – 2019-02-05T20:45:24.227

I had another idea just now. The nn flag can be completely replaced by n. – Nitrodon – 2019-02-06T19:38:16.363

@Nitrodon Great idea! That golfed a lot of bytes off – Jo King – 2019-02-07T02:23:38.360

6

05AB1E, 13 bytes

2096239D20BJ

Try it online!

Beats all the string-based 05AB1E quines.

Explanation:

2096239            # integer literal
       D           # duplicate
        20B        # convert the copy to base 20, yielding "D20BJ"
           J       # join with the original

Grimmy

Posted 2011-01-28T00:34:05.293

Reputation: 12 521

6

Whitespace, 338 bytes

-3 bytes thanks to Dorian pointing out a mistake

   	 		   		      	    	  			    	     		 	 	 	 		  				  	      	     		  	   				     			 		   						  	 		 		  					    			  					    	 	  				       				 	    	 	  	   		 	 				 	  	   		 	  					 	 					 
   	 

 	 

 	 

 	
   	
	   
  
 	  	
 	  	
	 	  
 
	 	
 	  	

 	
	 		 
 
	 	
   	   
	   	
  
	

  	
 


   
   	     
	
  
	

Try it online!

Not really much to see, but the code is there. This terminates with a 'Can't return from subroutine' error, which is only about 10 or so bytes extra to remove. Translated from whitespace, the tokens are:

push 213928514417226051472880134683878051755207959239232598316788086
push 2
call PRINT_SPACE
call PRINT_SPACE
call DIV_MOD_PRINT
push 1
add

label DIV_MOD_PRINT
    copy 2nd item in stack
    copy 2nd item in stack
    div
    jump if zero to POP_AND_PRINT_SPACE
    copy 2nd item in stack
    call DIV_MOD_PRINT
    mod
    dupe
    jump if zero to POP_AND_PRINT_SPACE
    push 8
    add
    print as character
    return

label POP_AND_PRINT_SPACE
    pop
    label PRINT_SPACE
        push 32
        print as character
        return

This starts off by pushing a rather large number in binary spaces and tabs. This number represents the rest of the program in trinary (since Whitespace has 3 valid characters), with space being 0, tab being 1 and newline as 2.

The main part of this code is the DIV_MOD_PRINT function, which assumes that the large number and the divisor is on top of the stack. This makes a copy of the two elements, then divides the number by the divisor and recursively calls the function again, returning once the result of the division is zero. On the tail call, this takes the two copied elements and gets the remainder after division. Then it maps it to the representation above.

This function is reused twice on the large number we pushed at the beginning, once with the divisor 2 to print the number itself in tabs and spaces, and again with 3 to print the rest of the program.

There are a couple of caveats; for example, we can't represent leading spaces with leading zeroes, so we with have to print those manually before we call the function the first time. This is partially mitigated by the fact that we stop the recursion by jumping to the POP_AND_PRINT_SPACE label, which means that we print a leading space anyway.

However, that causes one of the modulo pairs not to be evaluated, therefore the last character represented is not printed. This is actually a good thing, for a couple of reasons. First, since the binary number representation is terminated with a newline which would have had to have been printed (since we print a leading space), instead, if we ensure the last character of the binary number is a space, the newline is now the first character of the rest of the program. We can make the last character a space easily, since we aren't printing the last character of the program by adding a space or tab when encoding the number literal.

For reference, my encoding program, my commented program, and I used WhiteLips to debug the program.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

6

Klein, 330 bytes

"![	.;	=90*/[	.9(#;	=[>[.	>1#	98='9[	'7[.>;	[*;	)	=#0,*[	=.>9(.	=*(#(#([	.0#8;#(#;	[*9>[;	=> [*?	[9(;;"\
/																																																																																																														<
>:1+0\
 /:)$<
>\?\ /
?2 $
:9>(:\
(8\/?<
\+ <
 *
 >$1-+\
>/?:) /
 >+)$)$)\
/1$9<$)$<
\+:?\<
>?!\+@
\:)<<

Try it online!

This works in all topologies, mostly by completely avoiding wrapping. The first list encodes the rest of the program offset by one, so newlines are the unprintable (11).

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

6

Clojure, 91 bytes

((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x)))))

mikera

Posted 2011-01-28T00:34:05.293

Reputation: 1 233

6

JavaScript (ES6), 28 26 bytes

Run this code in Firefox 34+ (currently in Aurora)'s Web console

(f=x=>alert`(f=${f})()`)()

Optimizer

Posted 2011-01-28T00:34:05.293

Reputation: 25 836

Hmm... doesn't work in the latest version of Firefox (it outputs (f=,)()), I believe you'd have to put the template in parentheses. – ETHproductions – 2017-08-11T19:34:15.330

@rafe-ketler - I believe that this is the shortest ES6 version now :) – Optimizer – 2014-09-13T22:50:04.483

6

Commodore Basic, 54 41 characters

1R─A$:?A$C|(34)A$:D♠"1R─A$:?A$C|(34)A$:D♠

Based on DLosc's QBasic quine, but modified to take advantage of Commodore Basic's shortcut forms. In particular, the shorter version of CHR$(34) makes using it directly for quotation marks more efficient than defining it as a variable.

As usual, I've made substitutions for PETSCII characters that don't appear in Unicode: = SHIFT+A, = SHIFT+E, | = SHIFT+H.

Edit: You know what? If a string literal ends at the end of a line, the Commodore Basic interpreter will let you leave out the trailing quotation mark. Golfed off 13 characters.

Alternatively, if you want to skirt the spirit of the rules,

1 LIST

LIST is an instruction that prints the current program's code. It is intended for use in immediate mode, but like all immediate-mode commands, it can be used in a program (eg. 1 NEW is a self-deleting program). Nothing shorter is possible: dropped spaces or abbreviated forms get expanded by the interpreter and displayed at full length.

Mark

Posted 2011-01-28T00:34:05.293

Reputation: 2 099

Its not opening the file and reading its input, but I do agree that this is a bit cheaty. – YoYoYonnY – 2015-02-26T21:34:15.573

@MartinBüttner, is the new version better? – Mark – 2015-02-27T07:53:14.560

@Mark I can't read that, but it looks like a quine to me. ;) – Martin Ender – 2015-02-27T09:06:13.900

@YoYoYonnY It reads its source, tho. – Erik the Outgolfer – 2016-06-28T21:54:27.790

6

Lua, 44 bytes

s="s=%qprint(s:format(s))"print(s:format(s))

Some other comical answers in Lua:

print(arg[0])

...so long as the file is named print(arg[0]) And...

Lua: quine.lua:1: function arguments expected near '.'

...so long as the file is named quine.lua

thenumbernine

Posted 2011-01-28T00:34:05.293

Reputation: 341

6

Mathematica, 68 bytes

Print[#<>ToString[#,InputForm]]&@"Print[#<>ToString[#,InputForm]]&@"

celtschk

Posted 2011-01-28T00:34:05.293

Reputation: 4 650

6

Vitsy, 11 9 8 6 Bytes

This programming language was obviously made past the date of release for this question, but I thought I'd post an answer so I can a) get more used to it and b) figure out what else needed to be implemented.

'rd3*Z

The explanation is as follows:

'rd3*Z
'           Start recording as a string.

(wraps around once, capturing all the items)

'           Stop recording as a string. We now have everything recorded but the original ".
 r          Reverse the stack
  b3*       This equates the number 39 = 13*3 (in ASCII, ')
     Z      Output the entire stack.

Addison Crump

Posted 2011-01-28T00:34:05.293

Reputation: 10 763

6

ಠ_ಠ, 6 bytes

ಠಠ

This used to work back when the interpreter was still buggy but that's fixed now. However, you can try it in the legacy version of the interpreter!

Mama Fun Roll

Posted 2011-01-28T00:34:05.293

Reputation: 7 234

2It seems that also works in the interpreter provided. Also, ಠ is 3 bytes in UTF-8 – Conor O'Brien – 2016-08-19T21:53:23.813

Your link is dead, and can you upload the language source to GitHub so that it can be added to TIO? – Pavel – 2017-01-30T04:28:47.773

http://codepen.io/molarmanful/pen/rxJmqx all the code happens to be there. – Mama Fun Roll – 2017-01-30T17:58:03.387

6

Julia, 37 bytes

x=:(print("x=:($x);eval(x)"));eval(x)

Now that I know a bit more Julia, I thought I'd revisit this... due to the way printf works in Julia, my previous approach is clearly unsuitable. Instead we make use of (the tip of the iceberg of) Julia's homoiconic features. We define a symbol (that is, a representation of Julia code) which prints the framework of the code, as well as the contents of the variable x (via interpolation) and store that symbol in x. Then we eval that symbol. Much better. :)

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

6

beeswax, 17 13 bytes

Non-competing answer, beeswax is from 2015.

According to the discussion on Does using SMBF count as a cheating quine? the original version at the bottom would count as a cheating quine, so I am wondering if a small change would make this a “proper” quine. The new version is 4 bytes smaller and does not modify its own source code:

`_4~++~+.}1fJ

Explanation:

                lstack     STDOUT

 _             α[0,0,0]•                 create bees α,β, moving right and left
               β[0,0,0]•

` 4            α[0,0,4]•                 push 4 on top of α lstack, switch β to print mode
β α            β[0,0,0]•                 switch β to character output mode

   ~           α[0,4,0]•                 flip α lstack top and 2nd
    +          α[0,4,4]•                 lstack top = top+2nd
     +         α[0,4,8]•                 lstack top = top+2nd
      ~        α[0,8,4]•                 flip lstack top and 2nd
       +       α[0,8,12]•                lstack top = top+2nd
        .      α[0,8,96]•                lstack top = top*2nd
         }     α[0,8,96]•    ` ASCII(96) output char(lstack top) to STDOUT
          1    α[0,8,1]•                 lstack top = 1
           F   α[1,1,1]•                 all lstack = top
            J  α[1,1,1]•                 jump to (x,y) = (lstack top, lstack 2nd)
`_4~++~+.}1FJ  α[1,1,1]•   _4~++~+.}1FJ  output characters to STDOUT

This version should qualify as proper quine if the Befunge-93 program on Thompson’s Quine Page is listed as proper quine. The Befunge quine below does nothing else than read itself character by character, one character during each implicit loop, and output the character to STDOUT.

:0g,:93+`#@_1+

Correct me if I’m wrong.


Old (cheating?) version.

beeswax is a new 2D esolang on a hexagonal grid. It is inspired by bees, honeycombs and by the Hive board game (which uses hexagonal gaming pieces). beeswax programs are able to modify their own code. Thanks to this ability it is not too hard to create a quine. But the program does not read its own source code, as my explanation shows.

The first beeswax quine in existence:

_4~++~+.@1~0@D@1J

Or equivalently:

*4~++~+.@1~0@D@1J

IPs are called bees, the program area is called honeycomb. Every bee owns a local stack called lstack, carrying 3 unsigned 64 bit integer values.

Explanation:

                                             lstack
                                     • marks top of stack

* or _  create bee(same result in this situation)[0,0,0]•
 4      1st lstack value=4                       [0,0,4]•
  ~        flip 1st/2nd lstack values            [0,4,0]•
   ++      1st=1st+2nd, twice                    [0,4,8]•
     ~                                           [0,8,4]•
      +                                          [0,8,12]•
       .         1st=1st*2nd                     [0,8,96]•
        @  flip 1st/3rd lstack values            [96,8,0]• 
         1     1st=1                             [96,8,1]•
          ~                                      [96,1,8]•
           0   1st=0                             [96,1,0]•
            @                                    [0,1,96]•
             D drop 1st at row=2nd,col.=3rd val. [0,1,96]•
       This drops ASCII(96)= ` beyond the left border.

Dropping a value at a coordinate outside the program—in this case at column 0—grows the honeycomb by 1 column to the left. The coordinate system gets reset, so this column becomes the new column 1. So, growing the honeycomb in ‘negative’ direction is only possible in steps of 1. The grown honeycomb is always a rectangle encompassing all code.

This modifies the program to:

`*4~++~+.@1~0@D@1J

continuing...

               @                                  [96,1,0]•
                1                                 [96,1,1]•
                 J jump to row=1st,column=2nd val.[96,1,1]•
`                  switch to character output mode.
 *4~++~+.@1~0@D@1J    the following characters are printed to STDOUT.

GitHub repository of the Julia package of the beeswax interpreter.

M L

Posted 2011-01-28T00:34:05.293

Reputation: 2 865

6

Jolf, 4 bytes

Q«Q«
Q    double (string)
 «   begin matched string
  Q« capture that

This transpiles to square(`Q«`) (I accidentally did string doubling in the square function), which evaluates to Q«Q«. Note that q is the quining function in Jolf, not Q ;).

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

6

Fuzzy Octo Guacamole, 4 bytes

_UNK

I am not kidding. Due to a suggestion by @ConorO'Brien, K prints _UNK. The _UN does nothing really, but actually sets the temp var to 0, pushes 0, and pushes None.

The K prints "_UNK", and that is our quine.

Rɪᴋᴇʀ

Posted 2011-01-28T00:34:05.293

Reputation: 7 410

I was bored today and decided to quine in FOG. Couldn't figure it out, this is very clever – Bald Bantha – 2016-06-26T19:43:22.123

6

Bash + coreutils, 18 bytes

sed p<<a
sed p<<a

It requires a trailing newline and generates a warning.

Posted the Zsh version in a separate answer to fix the leaderboard.

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

Interesting use of the here-document, but one has to end the text stream manually with Ctrl+D to make the script run, hence the warning. To have it run automatically, an extra line with just a on it is required, but that would break the quine. – seshoumara – 2016-09-07T08:53:14.830

@seshoumara Just put it in a script file and use bash filename to run. – jimmy23013 – 2016-09-07T09:22:31.833

Aah, you give an EOF this way, nice. Maybe add that to description. I run it with bash script 2> /dev/null to get rid of STDERR. – seshoumara – 2016-09-07T09:31:29.967

In dash and zsh, you don't need the trailing newline and it won't generate a warning. – Dennis – 2016-09-08T15:49:25.540

1@seshoumara Answers on this site should be functions or complete programs, and not code snippets in a REPL, by default. – jimmy23013 – 2016-09-08T21:12:45.130

6

C++, 286 284 236 bytes

Now with extra golf!

#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}

I'm currently learning C++, and thought "Hey, I should make a quine in it to see how much I know!" 40 minutes later, I have this, a full 64 114 bytes shorter than the current one. I compiled it as:

g++ quine.cpp

Output and running:

C:\Users\Conor O'Brien\Documents\Programming\cpp
λ g++ quine.cpp & a
#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

6

Cheddar, 56 bytes

var a='var a=%s;print a%@"39+a+@"39';print a%@"39+a+@"39

Try it online!

I felt like trying to make something in Cheddar today, and this is what appeared...

ETHproductions

Posted 2011-01-28T00:34:05.293

Reputation: 47 880

6

05AB1E, 19 bytes

Thanks to @Oliver for a correction (trailing newline)

"D34ç.øsJ"D34ç.øsJ

There is a trailing newline.

Try it online!

"D34ç.øsJ"             Push this string
          D            Duplicate
           34          Push 34 (ASCII for double quote mark)
             ç         Convert to char
              .ø       Surround the string with quotes
                s      Swap
                 J     Join. Implicitly display

Luis Mendo

Posted 2011-01-28T00:34:05.293

Reputation: 87 464

Try it online! - https://codegolf.stackexchange.com/a/161069/59376 - If you want to post this 22 byte answer on this question, you can :). Don't feel I deserve the credit. – Magic Octopus Urn – 2018-04-02T17:47:24.323

Probably wasn't available in the old version of 05AB1E yet when you posted your answer, but you can golf 2 bytes by changing sJ (swap, join) to ì (prepend). Try it online.

– Kevin Cruijssen – 2018-09-07T12:17:10.540

@KevinCruijssen Thanks. I like to keep the language as it was before the challenge (even though that's not required anymore), so I'll leave it as it is – Luis Mendo – 2018-09-07T13:21:39.590

1@LuisMendo Fine by me. There are already two shorter 05AB1E answers anyway. Was just stating it as a possibility. :) – Kevin Cruijssen – 2018-09-07T13:24:01.017

6

05AB1E, 16 17 bytes

"34çs«DJ"34çs«DJ

With trailing newline.

Try it online!

Explanation:

"34çs«DJ"        # push string
         34ç     # push "
            s«   # swap and concatenate
              DJ # duplicate and concatenate

acrolith

Posted 2011-01-28T00:34:05.293

Reputation: 3 728

5

Japt, 9 bytes

I've fantasized about a 9-byte Japt quine for years, and now it's finally snapped into place :-D

9îQi"9îQi

Test it online!

Explanation

    "9îQi    Start with this string.               9îQi
  Qi         Insert it before a quotation mark.    9îQi"
9î           Repeat until it reaches length 9.     9îQi"9îQi

ETHproductions

Posted 2011-01-28T00:34:05.293

Reputation: 47 880

5

Befunge-93, 25 22 bytes

-2*6<>:#,_@#:-5: _-p<"

Try it online!

Thanks to jimmy23013's answer for inspiring the idea to create the " before the wrapping string literal.

Previous answers have usually relied on non-standard interpreter behaviour in order to wrap a string literal around the code and avoid the extra spaces. My quine however, is compliant with Befunge-93 specs.

Befunge-93 has a bounding box of 80x25 cells, which are initially filled with spaces. This means the wrapping string literal, a staple of 2D quines, usually fills the stack with a lot of excess spaces.

How It Works:

-2*6<  Create the " character
                     " Start the wrapping string literal
                 _-p<  Pop all the spaces until there are none left
                       Note that p is the put command, which basically pops 3 items from the stack
            :-5:  Dupe the 2 and subtract 5 to replace the - that was destroyed
                  Dupe that again to compensate for the _
     >:#,_@#  Print until stack is empty and terminate

Alternatively:

++9*5<>:#,_@#::_$#-< "

also works for 22 bytes.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

5

Perl 6, 31 27 bytes

<"<$_>~~.EVAL".say>~~.EVAL

Try it online!

No messing about with alternative q quotes or .perl, just <> and a good ol' EVAL quine.

Explanation:

<                 >         # Create a list of 
 "<$_>~~.EVAL".say          # The string '"<$_>~~.EVAL".say'
                   ~~       # Smartmatch the list by setting $_ to it
                     .EVAL  # Evaluate the string as code
 "<$_>~~.EVAL"              # Interpolate the $_ list into the string
              .say          # And print it with a newline

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

5

1+, 834 bytes

(|11+"*"+"1+\1+/)("|1/()11+^)(2|\""++1+/()""+^)++<+/(#|\##"\+;1#()\^\1#)+<+()()(")(2)(2)()()(")()(2)(")(2)()(")()(")()()()(2)(")()()()(2)()()(2)()(")()()()()(2)(2)(")()()()(2)()()(2)()(")(2)()(")(2)(")()(")()()()(2)(")(2)(2)()(")()(2)(")()()()(2)()()(2)()(")(")()(")()(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()(")(2)(")()()(2)()(")()(2)(")(2)(2)()()(")()(2)(")()(2)(")(2)()(")()()()()(2)(2)(")()(2)(")(")(")(2)()(")(2)(")()()(2)()(")()(2)(")()()()(2)(")()(2)(")()(2)(")(")(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()()()(2)()(")(2)(")(2)()(")()()()()(2)(2)(")()(2)(")()()()(2)(")()()()(2)(")(2)()(")(2)(")()()(2)()(")()()()(2)(")(2)()(2)()(2)(")(")(2)(")(2)()(")()()(2)()(")()(2)(")()()()(2)(")()()()(2)()()(2)()(")()(2)(")()()()(2)(")(")()(2)(")(")(2)()()(")(")()(2)(")()()()(2)(")()()()(2)(")(2)()(2)()(2)(")(2)(")(2)()()(2)(")(")(#)@

Try it online!

Defines all the subroutines before the data section, then calls the (#) subroutine at the end of the data. Instead of using 1s followed by totalling 1+s, we define subroutines for initialisation ((")), which pushes a 2 to the stack, incrementing (()), and doubling plus 2 (ironically, (2)). All of these also push the characters used to call the subroutine to the top of the stack to print after printing the rest. We also offset the data by 32, since all values are above that.

This is most certainly suboptimal, especially since I've been steadily golfing it down from ~2000 bytes. I suspect it can be sub-500 eventually, or even lower with a different strategy.

Here's my program encoder, though it needs some post-fiddling with the first value to make sense.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

5

Pyth, 9 8 bytes

p+N
"p+N

Saved one more byte by using the newline operator

(Also I made this ages ago but forgot to edit this so yeah)

Try it online!

EdgyNerd

Posted 2011-01-28T00:34:05.293

Reputation: 1 106

5

C++ (350)

#include<iostream>
#include<fstream>
int main(){std::ofstream f;f.open("f.cpp");
#define B(x)x;f<<("B(" #x ")");
#define A(x)f<<("A(" #x ")");x;
B(f<<("#include<iostream>\n#include<fstream>\nint main(){std::ofstream f;f.open(\"f.cpp\");\n#define B(x)x;f<<(\"B(\" #x \")\");\n#define A(x)f<<(\"A(\" #x \")\");x;\n"))A(f<<("f.close();}\n"))f.close();}

Modified version of this.

Makes use of the C++ preprocessor.

Mateen Ulhaq

Posted 2011-01-28T00:34:05.293

Reputation: 1 889

5

Arcyóu, 1 byte

Q

The interpreter evaluates undefined symbols as strings, and the result of the last expression evaluated is automatically printed at the end of the program. What's interesting is that any undefined identifier can be used; I_am_a_quine! is also a quine.

jqblz

Posted 2011-01-28T00:34:05.293

Reputation: 2 062

1

This does not satisfy our rules for proper quines as the Q only encodes itself (as does any character in I_am_a_quine!).

– Martin Ender – 2017-05-23T15:35:41.030

Agreed @MartinEnder, but the challenge does not specify proper quines. – jqblz – 2017-06-02T21:30:24.970

4

tinylisp, 88 bytes

The byte count includes a trailing newline.

((q (g (c (c (q q) g) (c (c (q q) g) ())))) (q (g (c (c (q q) g) (c (c (q q) g) ())))))

Try it online!

There are no strings in tinylisp, but a nontrivial quine is still possible because code is lists and lists are code. The above code is a list which, when evaluated, returns (and therefore prints) itself.

The idea is to pass the list (g (c (c (q q) g) (c (c (q q) g) ()))) to a function which will wrap it in a list, tack a q on the front, and then wrap two copies of that in a list. Which is exactly what the function (q (g (c (c (q q) g) (c (c (q q) g) ())))) does. In-depth explanation available on request, but I wanted to post this before turning in for the night.

DLosc

Posted 2011-01-28T00:34:05.293

Reputation: 21 213

4

C++, 117 bytes

#include<cstdio>
#define Q(S)char*q=#S;S
Q(int main(){printf("#include<cstdio>\n#define Q(S)char*q=#S;S\nQ(%s)",q);})

Ralph Tandetzky

Posted 2011-01-28T00:34:05.293

Reputation: 215

1What compiler does this use? This does not appear to work on gcc. – Post Rock Garf Hunter – 2017-01-13T15:26:59.500

It works on my gcc 4.9.2. – Ralph Tandetzky – 2017-01-13T15:38:22.537

2Ok. According to clang, this is not valid C++, since the return type of main() is missing. I fixed that now. – Ralph Tandetzky – 2017-01-13T15:40:40.627

My version of gcc was 4.2.1 (I should update some time). Now that main has a return type it works. – Post Rock Garf Hunter – 2017-01-13T15:47:41.360

4

Befunge-98 (cfunge), 8 characters

 'k<@,k␇

represents a literal BEL character (ASCII 7, or Ctrl-G). (Note also that the program starts with a leading space.)

Note that the k command, which is heavily used here, is somewhat imprecisely defined, and this code is outright exploiting several edge cases at once, making this an example of corner-case code. As such, this is somewhat interpreter-dependent; it doesn't work on TIO, for example. cfunge is the Befunge-98 interpreter I normally use locally (and has been tested to be highly conformant with the specification), and it handles this code correctly. (Update: I've been talking to some Befunge experts about this quine, and the consensus is that it's exploiting a bug in cfunge, not behaviour that's defensible by the specification. Still a valid answer, though, because languages are defined by their implementation and this is the sort of corner case that has no right answers, only wrong answers.)

This program would also work in Unefunge-98 and Trefunge-98, but I'm not sure if any of the pre-existing interpreters for those handle k in the way we need, so it may be noncompeting in those languages.

Verification

$ xxd /tmp/quine.b98
00000000: 2027 6b3c 402c 6b07                       'k<@,k.
$ ./cfunge /tmp/quine.b98 | xxd
00000000: 2027 6b3c 402c 6b07                       'k<@,k.

Explanation

General principles

We know that in fungeoids, it's normally easiest to wrap a string around the code, so that the code is inside and outside the string literal at the same time. However, another trick for shortening quines is to use a string representation which doesn't need escaping, so that we don't need to spend bytes to represent the string delimiter itself. So I decided to see if these techniques could be combined.

Befunge-98 normally uses " as a string delimiter. However, you can also capture a single character using ', and you can make any command into a sort of lightweight loop (in a confusing and buggy way) using k. As such, k' functions as a sort of makeshift length-prefixed string literal. And of course, a length-prefixed string literal has no problems in escaping its own delimiter, as it doesn't have any sort of string terminator at all, meaning that the entire range of octets (in fact, the entire range of cell values) are available to exist within the string.

We can actually do even better; we no longer have to stop the string at its opening delimiter (we can stop it anywhere), so we can wrap it multiple times around the program to grab not only the k' itself, but also the length of the string (which is in this case written as a character code, thus the literal backspace). The program will continue execution just after the end of the string, i.e. just after the last character captured, which is exactly where we want it. (Bear in mind that Befunge strings are printed in reverse order to pushing them; the most common form, NUL-terminated strings, are called "0gnirts" by the community because of this, and length-prefixed strings follow the same principle. Thus if we want the length to end up at the start of the string, we have to push it last.)

As an extra bonus, this also means that we can wrap multiple times around the program with no penalty; all that matters is that the last character we see is the string length (which is at the end of the program). By an amazing stroke of luck, k' specifies length-prefixed string (sort-of; k is weird), and 'k (the same two characters in reverse order) pushes 107, which happens to loop round the program multiple times and end up in exactly the right place (this only had a 1 in 8 chance of working out). Because we have to reverse the program direction anyway (to read the string in the reverse of the natural reading order, meaning that it gets printed in the same order it appeared in the original program), we can use the same two characters for both pushing the length, and pushing the string itself, at no cost.

Of course, this now captures a risk of counting as a literal-only program, and thus not a proper quine under PPCG rules. Luckily, wrapping round from one end of the program to the other produces a literal space character, and spaces at the ends of the line (i.e. leading and trailing whitespace) aren't captured as part of a string. Thus, if we start the program with a space, we can encode that space (which isn't part of the string literal) via the implicit space that we get from wrapping the program (i.e. the leading space is encoded by the ' next to it, rather than by itself), just sneaking within the proper quine rules. The easiest way to see this is to delete the leading space from the program; you'll get the same output as the program with the leading space (thus effectively proving that it doesn't encode itself, because even if you remove it it still gets printed).

Detailed description

 'k<@,k␇
 'k       Push 107 to the stack
   <      Set execution delta to leftwards
 'k       Push the next 107 characters to the stack: "'␠␇k, … @<ck'␠␇"
     ,k   Pop a length from the stack, output that many characters
     ,    Output the top stack element
    @     Exit the program

You can note that k has some odd ideas of where to start reading the string from (for the first k that runs), or where to leave the IP afterwards (for the second k that runs); this is just the way k happens to work (you think of k as taking an "argument", the command to run, but it doesn't actually move the IP to skip the "argument"; so if the command inside the loop doesn't affect the IP or the IP's movement, it'll end up being the next command that runs and the loop runs one more time). The literal BEL, ASCII 7, is interpreted by the second k as a loop counter, so the , inside the k will print the first 7 characters, then the , outside the k (which is the same character in the source) will print the 8th just before the program exits.

user62131

Posted 2011-01-28T00:34:05.293

Reputation:

4

Brachylog (2), 26 bytes, language postdates challenge

"ạ~bAh34∧A~ạj"ạ~bAh34∧A~ạj

Try it online!

A function that returns its own source code. (This can be made into a 28-byte full program by adding w after each occurrence of j.)

Explanation

"ạ~bAh34∧A~ạj"ạ~bAh34∧A~ạj
"ạ~bAh34∧A~ạj"               String literal
              ạ              Convert to list of character codes
               ~b            Prepend an element
                  h34          so that the first element is 34
                 A   ∧A        but work with the entire list
                       ~ạ    Convert to string
                         j   Concatenate the string to itself

user62131

Posted 2011-01-28T00:34:05.293

Reputation:

4

Operation Flashpoint scripting language,  22  15 bytes

q={"q={"+q+"}"}

Call with:

hint call q

Output:

q={"q={"+q+"}"}

Old version (22 bytes):

q={format["q={%1}",q]}

Steadybox

Posted 2011-01-28T00:34:05.293

Reputation: 15 798

4

Ruby, 27 bytes

eval s="$><<'eval s=';p s"

Try it online!

$><<'...' is equivalent to print'...' (outputs the string without a newline).

Note the newline at the end of the program.

Nnnes

Posted 2011-01-28T00:34:05.293

Reputation: 395

Welcome to the site! Nice first answer :) – James – 2017-06-12T17:07:23.263

1doesn't p print a newline? – Shelvacu – 2019-08-11T23:20:30.133

@Shelvacu You're right; it should be 27 bytes. Interestingly, I went back and looked around, and I couldn't find any Ruby quines that included a newline in their source to match the output. Most seem to add an extra newline in their output like this one did. I also have a vague memory of coming across a 25-byte Ruby quine somewhere, I think in a demonstration of a new-at-the-time feature, but I haven't been able to find it again. – Nnnes – 2019-08-12T23:43:50.670

4

Alice, 45 bytes

Credit to Martin Ender for the use of %, r, and y to obtain the characters "/\ without escaping.

/?.!eO%?.*y1?@~mtz!!4\
\"Y!Z1hrZRoY@*m*h%1Y{/

Try it online!

This program runs entirely in ordinal mode. Because of how ordinal mode programs need to be formatted, this is significantly longer than Martin Ender's cardinal mode quine.

In ordinal mode, the instruction pointer moves diagonally, and commands work on strings instead of integers. The diagonal movement is what makes this tricky: there is even a challenge specifically about formatting a program for ordinal mode. While it's possible to sidestep the entire issue by putting the same string on both lines, this approach ends up slightly longer at 52 bytes.

\".!e1%r.Ryh?*.Ooo1m@z1!{
\".!e1%r.Ryh?*.Ooo1m@z1!{/

Try it online!

Explanation

This is a standard template for ordinal mode, with an additional mirror to allow the program to loop back to the beginning. Linearized, the code is as follows:

".!e1%r.RyY?*~*t%!Y4?Y!ZOh?Z*o1@@mmhz1!{

As with many Fungeoid quines, the " wraps around to itself and puts this entire program in a string literal. Since string mode treats mirrors as mirrors (instead of literals), the string that gets pushed is exactly the linearized code, excluding the ".

.!     Duplicate the string, and move the copy to tape
e1%    Split on "1", placing "@@mmhz" and "!{" on top of the stack.
       The other two parts are irrelevant.
r      Expand !{ into the entire range from code point 33 to 123.
.R     Duplicate and reverse this range
y      Modify the string @@mmhz by changing every character in the range 33-123 
       with the corresponding character in the reversed range.
       The result of this transformation is \\//4" .
       This allows us to get these characters without escaping them.
Y?*~*  Split this string in half by unzipping, and put the halves on either
       side of the original string.  The new string is \/"sourcecode\/4 .
t%     Extract the newly added 4 at the end, and use it to split on the single 4 in the code.

At this point, we have two strings corresponding to approximately half of the code. The top of the stack has the second half of the program and the right side mirrors, and corresponds to these output bytes:

 ? ! O ? * 1 @ m z ! \
  Y Z h Z o @ m h 1 {/

The string below that has the first half of the program, along with the left side mirrors and quote:

/ . e % . y ? ~ t !
\" ! 1 r R Y * * % Y

Neither string currently contains the 4 that was used to split the string.

!      Move second half string to the tape.
Y      Unzip first half: the top of the stack now contains the characters
       from the first half that will end up in the first row of the output.
4      Append the digit 4 to this string.
?Y     Copy second half back from tape and unzip: the top of the stack contains
       characters from the second half that will end up in the second row
!      Move this onto the tape.
Z      Zip the two halves of the first row together.
O      Output this with a linefeed.
h      Temporarily remove the initial \ so the next zip will work right.
?Z     Copy the string back from the tape, and zip the second row together.
       This Z isn't the exact inverse of Y since the second half is longer.
       The resulting behavior is exactly what we want.
*o     Join with the previously removed \ and output.
1      Append 1 to the irrelevant string on the top of the stack.
@      Terminate.

The 52-byte quine works on exactly the same principle, except that it doesn't need the ordinal formatting section of the 45-byte quine.

Nitrodon

Posted 2011-01-28T00:34:05.293

Reputation: 9 181

4

Taxi, 1144 1034 970 bytes

"is waiting at Writer's Depot.34 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 r 3 l 2 l 3 l 2 r.Pickup a passenger going to Charboil Grill.Go to Charboil Grill:e 1 l.Pickup a passenger going to KonKat's.Go to Writer's Depot:w 1 r.Pickup a passenger going to KonKat's.Go to KonKat's:n 3 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Post Office:s 1 l 2 r 1 l."is waiting at Writer's Depot.34 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 r 3 l 2 l 3 l 2 r.Pickup a passenger going to Charboil Grill.Go to Charboil Grill:e 1 l.Pickup a passenger going to KonKat's.Go to Writer's Depot:w 1 r.Pickup a passenger going to KonKat's.Go to KonKat's:n 3 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Post Office:s 1 l 2 r 1 l.

Please ignore the output to stderr. Who needs a job if you can quine anyway?

Try it online!

How does this work?

Short answer

This quine starts with a string. If you replace the content of that string by <string>, the code looks like "<string>"<string>, which is "<string> twice. Because the string doesn't contain the double quote, we first get the double quote via its character code, concatenate it with the string, then copy the string and concatenate it with itself. Finally, we print the string.

Long answer

under construction

Luke

Posted 2011-01-28T00:34:05.293

Reputation: 4 675

4

JavaScript, 53 bytes

A quine without any uses of uneval or Function.prototype.toString.

Q="q=Q.link()[8];alert(`Q=${q+Q+q};eval(Q)`)";eval(Q)

Can avoid use of template strings for + 1 byte.

Q="q=Q.link()[8];alert('Q='+q+Q+q+';eval(Q)')";eval(Q)


JavaScript, 74 bytes

Another approach avoiding uneval and Function.prototype.toString:

console.log(a="console.log(a=%s%s%s,q=a.link()[8],a,q)",q=a.link()[8],a,q)

Dom Hastings

Posted 2011-01-28T00:34:05.293

Reputation: 16 415

4

Underload, 10 Bytes

(:aSS):aSS

Try it online!

Wurlitzer

Posted 2011-01-28T00:34:05.293

Reputation: 99

4

Pain-Flak, 2009 bytes

><))(())(())()(())(())()(())(())(())(())()()(())()(())(())()()()(())(())()(())(())()()(())(())(())()(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()(())(())(())()()(())()()(())(())(())()()(())(())(())()()()(())(())(())()()()(())(())()()(())()(())()()(())(())()()()(())(())(())(())(())(())()(())()()()(())()(())()()(())(())()()()(())(())(())()()()(())(())()()(())()(())(())()()(())()()(())(())(())()()(())(())(())(())(())(())()()()(())(())(())()()(())(())(())(())()()(())()()(())()()()(())(())()()(())()(())(())()()(())(())(())(())(())(())()()(())()()()(())(())()(())(())()()(())()(())()()(())()()()(())(())()()(())(())(())(())(())(())()()(())()()()(())()(())(())()(())()()(())(())()(())()()()()(())()(())(())(())(())(())(())(())(())()(())(())(())()()(())()(())(())(())(())(())()()()(())()(())(())()()(())(())(())()()(())()(())(())(())()()(())()(())()(())(())(())(())()()(())()(())()()()()(())()(())()(())()()()(())(())(())()(())(())()()(())(())(())()()(())()(())(())(())()()(())()(())()(())(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()()()(())(())()(())(())()()(())()(())()(())()()()(())()(())(())(())()(())()()()()(())()()(())(())()(())()(())(())(())(())()()(())(())(())()()()(())(())(())()()()(())(())()()(())()(())()()(())(())()()()(())(())(())()()()(())(())(())(())()(())(())(())(())()(())()()()()(())(())()()(())()(())()(())()(())(())()()()(())(())(())()(())(())()()(())()(())()()(())()()()(())(())()(())(())(())(())()()(())()()()()(())()(())()(())(())()()()(())(())(())()(())(())(())()()(())(())(())()()(())(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()(())()(())(())()()()(())()()((}><))))))()()()()((}{(}{(}{()((><))]}{[()(>})}{)((><)))}{])([()(((><{><})}{><(><{}{<())(}])([)>))}{)(>))))()()()()((}{())}{()}{(}{)((>))])}{([))}{()}{(}{)><((()}{()((<(<(()])(})()>}{<({[}{>})}{)(>}{<({<}{)}{>}}{{<}{(><(<({}{(}}{)}{><(><})>)(<({{><})}{><(><{}{{}}{{)))))()()()((}{)((}{)(><)}{(()()((

Try it online!

(Trailing newline because the interpreter outputs a newline.)

-176 bytes by improving the Brain-Flak quine

Basically a straight port of my Brain-Flak quine. The only major difference is the >< at the beginning, which is required in order to keep the data section out of the output.

><                 switch to right stack; effectively does nothing since both stacks are empty
))((...))()()((    data, same format as the Brain-Flak quine
}main loop{        same as the Brain-Flak quine, but with different constants
}}{{               clear current stack; this does nothing
)))))()()()((}{)((}{)(><)}{(()()((   push opening >< at beginning of code

Since this is Pain-Flak, the code also goes backward after it is finished going forward. As such, I had to ensure that this does not mess up the output.

))()())}{(><)(}{))(}{))()()()(((((   push 70, 68, 5, 4 on right stack
}}{{               clear right stack
}pool niam{        do nothing because top of stack is zero
))()()((...))((    push constants on right stack in reverse order
><                 switch to left stack and implicitly output

Nitrodon

Posted 2011-01-28T00:34:05.293

Reputation: 9 181

1The only Pain-Flak solutions I've seen are ones directly translated from Brain-Flak... – Jo King – 2018-04-10T05:21:43.523

I will give the bounty but kinda lame that it is just a port – Christopher – 2018-04-25T10:39:39.153

@Christopher it is your fault that you made Pain-Flak so similar to Brain-Flak :P – ASCII-only – 2018-04-30T22:13:20.250

@ascii painflak update is removing swap stack – Christopher – 2018-04-30T22:47:24.830

@Christopher then it'll just be translated Mini-flak? – ASCII-only – 2018-04-30T23:09:57.217

4

Whitespace, 406 bytes

DISCLAIMER: This quine was not created by me, it is created by Smithers. Because this challenge was missing a Whitespace answer I decided to post his/her. If Smithers reads this and wants to post it himself/herself I will of course delete my answer.
Sources: Smithers' website and his/her Whitespace quine source code (note: it's missing a trailing new-line).

[S S S T    S S T   S T T   T   T   T   S T T   T   S S T   T   S S S T S T T   S T T   T   T   T   T   T   S T S S S T S S T   S S T   S T T   T   T   T   S T S T S S S T T   T   S S T   S T T   S S S S T   T   T   T   T   T   S S T   T   T   S T S T S S S T T   T   S S S S S S S T T   T   T   T   T   T   S T S S T   S S S T S T T   T   T   S S S S S T S T S S S T S T T   S T S S S T S S T   S S T   T   T   S S S S S S S T T   S T S S T   T   T   T   T   S S S T T   T   T   S S T   T   S T T   S S T   S T T   T   T   S S S S T   T   S S T   T   T   T   S T S S T   T   S S T   S S T   T   S S S S T   T   S S T   T   S S T   S S T   T   S T S T S T T   S S S T T   S T S N
_Push_67079405567184005086107571748115383207539763039497665210559156555730234138][S N
S _Duplicate][N
S T S N
_Call_Label_PRINT_SPACE][N
S T S N
_Call_Label_PRINT_SPACE][S S S T    S N
_Push_2][S N
T   _Swap][N
S T N
_Call_Label_RECURSIVE_PRINTER][S S S T  S T S N
_Push_10][T N
S S _Print_as_char][S N
N
_Drop][S S S T  T   N
_Push_3][S N
T   _Swap][N
S T N
_Call_Label_RECURSIVE_PRINTER][N
N
N
_Exit][N
S S N
_Create_Label_RECURSIVE_PRINTER][S N
S _Duplicate][N
T   S T N
_If_0_Jump_to_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S T  S S T   N
_Copy_1][S T    S S T   N
_Copy_1][S T    S S T   N
_Copy_1][T  S T S _integer_divide][N
S T N
_Call_Label_RECURSIVE_PRINTER][T    S T T   _Modulo][S N
S _Duplicate][N
T   S T N
_If_0_Jump_to_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S S S T  S S S N
_Push_8][T  S S S _Add][T   N
S S _Print_as_character][N
T   N
_Return][N
S S T   N
_Create_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S N
N
_Discard][N
S S S N
_Create_Label_PRINT_SPACE][S S S T  S S S S S N
_Push_32][T N
S S _Print_as_character][N
T   N
_Return]

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

Whitespace is a stack-based language only using three characters: spaces, tabs and new-lines. In Whitespace the stack can only contain integers, and there are two options to print something to STDOUT: "Print as number" and "Print as character". In the case of "Print as character" it will print the character based on the unicode value at the top of the stack. Because whitespace uses spaces, tabs and new-lines, it means it'll have to print numbers 32, 9, and 10 respectively as characters to STDOUT for this quine.

Smithers uses a pretty ingenieus piece of code with the magic number (s)he found.

Pseudo-code:

Push 67079405567184005086107571748115383207539763039497665210559156555730234138
Duplicate top
Call function_PRINT_SPACE
Call function_PRINT_SPACE
Push 2
Swap top two
Call function_RECURSIVE_PRINTER
Push 10
Pop and print top as character
Discard top
Push 3
Swap top two
Call function_RECURSIVE_PRINTER
Exit program

function_RECURSIVE_PRINTER:
  Duplicate top
  If 0: Call function_DISCARD_TOP(_AND_PRINT_SPACE)
  Make a copy of the 2nd top item of the stack
  Make a copy of the 2nd top item of the stack
  Make a copy of the 2nd top item of the stack
  Integer-divide top two
  Call function_RECURSIVE_PRINTER
  Modulo top two
  Duplicate top
  If 0: Call function_DISCARD_TOP(_AND_PRINT_SPACE)
  Push 8
  Add top two
  Pop and print top as character
  Return

function_DISCARD_TOP(_AND_PRINT_SPACE):
  Discard top
function_PRINT_SPACE:
  Push 32
  Pop and print top as character
  Return

It first uses a recursive-loop which keeps integer-dividing the initial integer by 2 until it's 0. Once it's 0, it goes back over these values and does modulo-2, printing either a space (if the modulo-2 resulted in 0) or a tab (by adding 8 to the modulo-2 result of 1). This first part is used to print the magic number itself, which only consists of spaces and tabs, because pushing a number in Whitespace is done as follows (and thus doesn't contain any new-lines except for the single trailing one):

  • S: Enable Stack Manipulation
  • S: Push a number
  • S/T: Positive/Negative respectively
  • Some S/T, followed by a trailing N: The number as binary, where S=0 and T=1

After it has printed the spaces and tabs required for pushing the magic number itself, it pushes a 3 and will use the same recursive function with the magic number, integer-dividing and using modulo 3 instead of 2. Which will print the spaces (if the modulo-3 resulted in 0), or tabs/new-lines (by adding 8 to the modulo-3 result).

Kevin Cruijssen

Posted 2011-01-28T00:34:05.293

Reputation: 67 575

1

You may be interested in my new Whitespace quine

– Jo King – 2019-10-08T03:05:57.033

@JoKing Very nice! Well done! :) – Kevin Cruijssen – 2019-10-08T07:31:59.160

4

2DFuck, 1352 1289 bytes

!xv>>>>x>x>>>>>>x>x>x>x>>x>x>x>>x>x>>x>x>x>x>x>>x>x>>x>x>>x>x>x>x>x>>x>x>x>x>x>>x>x>x>x>>x>x>>x>x>x>>x>x>>x>>>x>>>>>>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>x>x>>>>>x>>>x>>>x>x>>x>x>x>x>x>>x>x>x>x>>>x>x>x>x>>x>x>x>x>x>x>>x>x>>>>>>>>>>x>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>x>x>>>>>x>>>x>>>x>x>x>>x>x>>x>x>>x>x>x>x>>x>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>x>x>x>>x>x>>x>x>x>x>x>>x>x>>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>x>>x>x>>x>x>>x>>>x>x>>>>x>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>>x>x>>x>x>x>>x>>>x>x>>>>>x>>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>x>x>>x>x>x>>x>x>>x>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>x>>x>x>x>x>x>x>>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>x>>x>x>x>x>x>>x>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>x>x>>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>x>x>x>>x>x>x>x>>>x>x>>>>x>>x>>>x>>>x>x>>x>x>x>x>>x>x>>x>x>x>>x>x>>>x>x>>>x>x>>>x>x>>>x>x>>>x>x>>>>>x>>>>x>x>>>>>>>>x>x>>>x>x>>>>>>>>>>x>x>>>>>x>>x>>>x>x>^x!..!.!....!.!.!....!....!...!.!..!.![<r!]![vr[!.!....!...]..!.....!.>^r!]![<r!]![vr[!..!.!.!...!.]r![>r[!..!.!....!.!]r![>r[>r[!.!.!.!...!.!.!]r![!.!.!.!..!.!..!]<]r![>r[!.!...!..!.!.]r![>r![!..!.....!.]r[>r![!..!....!..]r[>r![!.!.!.!....!.]r[>r[!.!....!...]r![!.!...!.!..!.]]]]]<]>]]>^r!]

Try it online!

Shaved off 63 bytes with Huffman coding! New explanation in progress.

wastl

Posted 2011-01-28T00:34:05.293

Reputation: 3 089

4

Reflections, 9228 bytes

As the program has 8620 lines, I won't put it here completely.

First line:

\

Then, for each character in the last part (below), there are n newlines for ASCII character n, followed by:

+
#

After it, the last part is (the # is actually already covered by the previous section):

#  /  \          /+\  /#_=0v\
>~ <       /(1:1)#@/       ~
\(0/      2)     \3)(2:2)(3^ 0#+#@
           \:(24):(4#_#_#_  /
      +               \*             (4\
      \*(1(2                          +/

Test it!

Working on explanation.

I had to fix a bug in the interpreter for this one. Does that count as adding a feature just for a challenge?

wastl

Posted 2011-01-28T00:34:05.293

Reputation: 3 089

1:| the URL encoding format is terrible – ASCII-only – 2018-05-22T00:57:08.747

4

Z80Golf, 120 bytes

00000000: 21f5 76e5 2180 10e5 21cd 00e5 2180 7ce5  !.v.!...!...!.|.
00000010: 21cd 00e5 21e1 7de5 2106 14e5 2110 e8e5  !...!.}.!...!...
00000020: 2100 80e5 21e5 cde5 211b 3ee5 2100 80e5  !...!...!.>.!...
00000030: 211a cde5 2180 13e5 21cd 00e5 211b 1ae5  !...!...!...!...
00000040: 2180 1be5 21cd 00e5 213e 21e5 2106 14e5  !...!...!>!.!...
00000050: 0614 3e21 cd00 801b 1b1a cd00 8013 1acd  ..>!............
00000060: 0080 1b3e e5cd 0080 10e8 0614 e17d cd00  ...>.........}..
00000070: 807c cd00 8010 f576                      .|.....v

Try it online!

Verification:

$ ./z80golf a.bin | xxd
00000000: 21f5 76e5 2180 10e5 21cd 00e5 2180 7ce5  !.v.!...!...!.|.
00000010: 21cd 00e5 21e1 7de5 2106 14e5 2110 e8e5  !...!.}.!...!...
00000020: 2100 80e5 21e5 cde5 211b 3ee5 2100 80e5  !...!...!.>.!...
00000030: 211a cde5 2180 13e5 21cd 00e5 211b 1ae5  !...!...!...!...
00000040: 2180 1be5 21cd 00e5 213e 21e5 2106 14e5  !...!...!>!.!...
00000050: 0614 3e21 cd00 801b 1b1a cd00 8013 1acd  ..>!............
00000060: 0080 1b3e e5cd 0080 10e8 0614 e17d cd00  ...>.........}..
00000070: 807c cd00 8010 f576                      .|.....v

$ ./z80golf a.bin | diff -s a.bin -
Files a.bin and - are identical

Looks like no one tried to make a proper quine in machine code yet, so here is one.

Although the machine code is loaded to memory, it does NOT read any address occupied by the code. Instead, it uses the stack space to setup required data.

Disassembly

start:
  ld hl, $76f5
  push hl
  ld hl, $1080
  push hl
  ld hl, $00cd
  push hl
  ld hl, $7c80
  push hl
  ld hl, $00cd
  push hl
  ld hl, $7de1
  push hl
  ld hl, $1406
  push hl
  ld hl, $e810
  push hl
  ld hl, $8000
  push hl
  ld hl, $cde5
  push hl
  ld hl, $3e1b
  push hl
  ld hl, $8000
  push hl
  ld hl, $cd1a
  push hl
  ld hl, $1380
  push hl
  ld hl, $00cd
  push hl
  ld hl, $1a1b
  push hl
  ld hl, $1b80
  push hl
  ld hl, $00cd
  push hl
  ld hl, $213e
  push hl
  ld hl, $1406
  push hl

  ld b, 20
loop1:
  ld a, $21
  call $8000
  dec de
  dec de
  ld a, (de)
  call $8000
  inc de
  ld a, (de)
  call $8000
  dec de
  ld a, $e5
  call $8000
  djnz loop1

  ld b, 20
loop2:
  pop hl
  ld a, l
  call $8000
  ld a, h
  call $8000
  djnz loop2

  halt

At start, the stack pointer sp is zero, just like other registers. Pushing some values causes sp to decrease, so the values are stacked in the memory region $ffxx.

The combination ld hl, $xxxx and push hl seems like the best option to dump predefined values into some memory space. It takes 4 bytes to store 2 bytes; any other option I could think of uses 3 or more bytes to store only one byte.

The first loop prints the ld hl, $xxxx (21 xx xx) and push hl (e5) instructions for the data, from the bottom of the stack (the address, represented by de, is decreased starting from $0000).

ld b, $xx and djnz label combined forms a fixed-times looping construct. It is only 4 bytes, which is optimal in Z80 (unless the loop count is already saved in another register).

But there is an endianness problem here, so simply sweeping the memory addresses in decreasing order does not work. So I had to add a pair of dec de and inc de at the cost of 2 bytes (plus 4 bytes to push the 2 bytes into the stack).

The second loop prints the main code by popping data from the stack.

Possible improvement ideas

Since the code is longer than $38 or 56 bytes, we can't use rst $38 in place of call $8000. Having call $8000 6 times in total, it's a great opportunity for golf. I considered placing call $8000; ret at address $38, but then I have to reduce the main code into 26 bytes or lower.

I also thought of moving the code to the front by adding some jr, so that I can embed the call $8000; ret in the code part. But then I can't use the efficient "pop and print" loop. It prints the data in reverse order of pushing, so it can't be used to print the push part; the "print" overwrites the stack with the return address, so it can't be used to print the first part either.

Finally, there is room for alternative encoding since some bytes frequently appear in the code. But Z80 itself is severely limited in arithmetic...

Bubbler

Posted 2011-01-28T00:34:05.293

Reputation: 16 616

4

MathGolf, 9 bytes

ÿ_'ÿ¬_'ÿ¬

Try it online!

Explanation:

ÿ_'ÿ¬_'ÿ¬
ÿ          Start string of length 4
 _'ÿ¬      Push "_'ÿ¬"
     _     Duplicate it
      'ÿ   Push the character "ÿ"
        ¬  Rotate stack so the "ÿ" is at the bottom
           Implicitly output "ÿ", "_'ÿ¬", "_'ÿ¬" join together

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

ÿ'ÿ¬_'ÿ¬_ is another 9-byter. – maxb – 2019-01-07T11:56:47.217

4

APL (Dyalog Unicode), 18 bytesSBCS

@ngn's updated version of the classic APL quine, using a modern operator to save four bytes.

1⌽,⍨9⍴'''1⌽,⍨9⍴'''

Try APL!

'''1⌽,⍨9⍴''' the characters '1⌽,⍨9⍴'

9⍴ cyclically reshape to shape 9; '1⌽,⍨9⍴''

,⍨ concatenation selfie; '1⌽,⍨9⍴'''1⌽,⍨9⍴''

1⌽ cyclically rotate one character to the left; 1⌽,⍨9⍴'''1⌽,⍨9⍴'''

Adám

Posted 2011-01-28T00:34:05.293

Reputation: 37 779

4

Keg, 49 43 bytes

\^\(\\\\\,\:\&\^\&\^\,\)\^\#^(\\,:&^&^,)^#

Try it online!

(note the trailing newline...)

-6 bytes thanks to Jo King reminding me that comments exist

This is a horrible mess, and I'm sure it can be outgolfed easily by someone comfortable with Keg's stack, and/or once "/' stop erroring. The first two thirds simply push each character from the last third to the stack in order (such that the last character is on top), and then the last third:

^                   Reverses the stack (such that the first character is on top),
 (         )        then does the following for each item CURRENTLY on the stack:
  \\,               print a backslash,
     :              duplicate the top of the stack,
      &             pop it to the register,
       ^            flip the stack,
        &           push the register,
         ^          flip the stack again,
          ,         and pop and print the top of the stack;
            ^       finally reversing what's left on the stack
             #\n    and commenting out the trailing newline,
                    so the stack is then implicitly printed bottom first,
                    with a trailing newline.

Essentially, it prints the first two thirds while copying itself onto the bottom of the stack, then flips the copy to be implicitly printed.

Unrelated String

Posted 2011-01-28T00:34:05.293

Reputation: 5 300

Thanks, fixed now... wait no – Unrelated String – 2019-10-01T05:15:40.753

Now it's fixed – Unrelated String – 2019-10-01T05:44:57.693

4

Keg, 21 bytes

HBZLTXJMIC(":,48*-)#

Try it online!

The string of letters translates to the code section reversed and shifted up by 32. It's lucky all the characters used are in the correct range for shifting.

Explanation:

(       )    # Loop over the stack
 "           # Shift stack left
  :          # Duplicate the letter
   ,         # Print the letter
    48*-     # Subtract 32 from the ordinal value of the letter
         #   # Comment out the newline
             # Print the shifted characters with a trailing newline

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

4

1+, 5424 4978 4808 4112 3962 3748 bytes

11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1111+1+1+1+1+1+1+1+1+1111+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1111+1+1+1+1+1+1+1+1+1111+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1111+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+11+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+11+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+(|11+1<)\(1|1""+""*++"*;)($|1+11#(1)1""+""*+""*++;1#1+"//"\^\<11+*#()*+\)(%|()#(1)($)"1+1<#)\(&|()#11+"*"*"++;\"1+1<#)

Try it online!

dzaima

Posted 2011-01-28T00:34:05.293

Reputation: 19 048

Congratulations! You beat me to the punch. Nice work!! – HighlyRadioactive – 2019-10-06T01:42:15.677

4

Whispers v2, 38 bytes

> "print('> %r\\n>> ⍎1'%a)"
>> ⍎1

Try it online!

Abuses the fact that there's an eval as Python command (), which I can use to turn it into an arbitrary Python program. But of course, as a less cheaty feeling quine, there's:

Whispers v2, 270 bytes

> [62, 62, 32, 34, 49, 34, 10, 62, 32, 34, 62, 32, 34, 10, 62, 62, 32, 51, 43, 50, 10, 62, 62, 32, 69, 97, 99, 104, 32, 54, 32, 49, 10, 62, 62, 32, 39, 82, 10, 62, 62, 32, 79, 117, 116, 112, 117, 116, 32, 52, 32, 53]
>> "1"
> "> "
>> 3+2
>> Each 6 1
>> 'R
>> Output 4 5

Try it online!

Which encodes the ordinal values of the rest of the program on the first line, then prints the list then the list converted to characters.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

4

CSS, 47 bytes

<style>:before,*{display:block;content:'<style>

Paste into a blank HTML page to avoid conflict with other tags.

Mama Fun Roll

Posted 2011-01-28T00:34:05.293

Reputation: 7 234

Wouldn't this technically be HTML with embedded CSS in it? Also, what browser did this successfully quine in, because when I test this with an empty HTML file, it displays :before,*{display:block;content:'<style> on the window. – Patrick Roberts – 2017-07-16T05:08:27.367

This doesn't work as HTML has implicit html, head and body tags. – Konrad Borowski – 2018-03-20T16:20:52.750

4

TeaScript, 1 byte

1

Nothing too interesting. But if that's too boring...

TeaScript, 3 bytes

[q|

and if that's to boring...

TeaScript, 15 bytes

(ƒ`(${f})()`)()

Downgoat

Posted 2011-01-28T00:34:05.293

Reputation: 27 116

4

JavaScript, 58 54 bytes

I present to you the shortest non-source-reading quine in JavaScript:

console.log(a="console.log(a=%s,uneval(a))",uneval(a))

How have I not thought of this before? Screw that, how has nobody thought of this before? :P

Here's a version that works in all browsers at the cost of 9 bytes:

q='"';console.log(a="q='%s';console.log(a=%s,q,q+a+q)",q,q+a+q)

ETHproductions

Posted 2011-01-28T00:34:05.293

Reputation: 47 880

If this works in the browser, you can make console.log be alert. – Conor O'Brien – 2016-09-07T01:56:36.643

1@ConorO'Brien Nope. The %s in the string only works with console.log. – ETHproductions – 2016-09-07T02:00:58.587

ahhh that's what that was. – Conor O'Brien – 2016-09-07T11:02:28.157

Lolp I was trying to do that a while ago, I couldn't figure out string formatting – Oliver Ni – 2016-10-23T05:26:57.943

4

BaCon, 54 bytes

Without using the SOURCE$ variable, the smallest Quine is 55 bytes:

s$="s$=%c%s%c:?34,s$,34 FORMAT s$":?34,s$,34 FORMAT s$

Peter

Posted 2011-01-28T00:34:05.293

Reputation: 119

2please make the main part of the post the 55 byte noncheating quine – Destructible Lemon – 2016-10-14T21:05:00.643

Done. I wonder why using 'SOURCE$' is cheating, looking at the other contributions? – Peter – 2016-10-15T20:05:24.100

1

The other answers are also cheating. This challenge is over five years old; most answers were posted before we had clearly defined rules. Since last month, improper quines are officially forbidden in all challenges, even if the spec doesn't explicitly forbid them.

– Dennis – 2016-10-15T20:13:29.807

Thanks for pointing me to this page, I was unaware of it. – Peter – 2016-10-16T20:29:20.193

3

BotEngine, 4x1=4 bytes

TRUE

The T instruction deletes the active bot and prints TRUE.

SuperJedi224

Posted 2011-01-28T00:34:05.293

Reputation: 11 342

3

Malbolge, 59851 Bytes, Non-competing.

I take no credit for this quine, all credit goes to this person

Newlines are significant, Compressed into a code snippet because otherwise this wouldn't fit.

var byteArray = pako.inflate(atob('H4sIAN89UFkCA5Rb+zty79P9/f4vSJRDKJFzFEJyCKXoQHKqRIoif/u7Zu7D3ru25/N9f3yuyzPXfc2eWbPWmun2Y3wrurmxvra6sBxZWgwvhILzc7OBmempSb9vYtw75hkd+e3/rPW6X5+d9ke9djG3/X1ao3/4JryF5mu+Xty++b4Q3a9Op31x/t5svtbrtf7Pt/wfE15v4QZ/VHv57vKfnLbm8CfO8J1274bDt95fRDPdwF8/Pz0+VO8TN7flXDGbuczn0tnMyvJ5+uz04Dh1lNw5iCX2dnfiE/z6pbX+N8J/frbbrdbb2yte8PIiniZ+HxC/+1vWj/loXb40Xx/rVQpfrt5X9nbLpWLh5npjY21tZSUSWVxcWAgG5+YCgWmE3/RNbCO8oOysqOxMU3bM8+/x/Nt+R4Z//WjV3pqvjdPaPb3+oFi5uy2XYtmb63zuau308kKk0snwCT8/sJ/YiuL521seJP93daUXXFr8XAi1EL45M10b8/uedPifwkf3K4/XX76/nb826scv4vnoENkp3NHzEX8zt3aWubyIpM8OkZ355GF8P7E36YvH1saiHrw+vNKLzC+GO6Fgy/ltBbL/+fNdkPFb7/R8Tv7hw8H93s1tvhSj7JxfrSH8+eJZOHScONo9xOv3/Jtxzs4IXv8dEoiP5wffJ+n5U5PPvqcH74+nR8//vmnJ8Bf8/Frq+Yi+7R6/vhDF66+ymWV6/elJUCTw/IP9qSmOP7ayGRlZ+/lZ7nYXO51Qi2pnpl6ffH6eeHgYq4yOfPV/ir3utaydt/Rr40SWzkFRIPvxHH3czXOOT7WzcJzao/D4uH5kh55PtbMcXJr7XPgItt5mfTPjdXr9eBWvv/stlb7Fzc1XLtfOZN7Pz19PT2upFLJT3a/cXce5dvIbV9nVy2MKz9/28GB6e29yZ2J9e3VscwSvX/nuLs2FA23RmnqffX2drtX8T4hf9dxxfArfaWdb7xfNJ1P5CVk7hZvoxQbXTorDBxE+HhNU+r4Ysr8cQWn+cGkGZoLz7/LjelRpdqk0C938W+c127q4aJ6d1Y+Pn5PJh/39yu5uORYTyL58/oXpLE7+rs8X83o9yxt4/sJy8I/k33LyqfKFrh1bfCR/+2bzIpdeyywvny8unoZCqbm5w5mZxCS/3kuws2gaS4YXOv799yiy0/n+GEj+81OSk4/S5G+bu6LK18mfnQUuTPl3NmJizRsd/dfzKyPl8k+Ba+dKvv6sXj3m8PeJ3Vsqzcw1ki+yMv4Cx98J4OOidiYQfnOUk99bWuxI1GzONCj5Twxrdxp2rvBtL16aT+LsBPGTj4fVROHueid2hewg+aunl8eRdBilOb9HuKCTHx0dXe/30bhLX2hcwM4bf9sX35Pg+Ldf5WKbnp8DKqN2qLOOj45uD6v7BaqdYnYLyV/PrpxcpJbOFhB+PhkIOEpToLOAO1/h9kxwsDRH8Px2gbKTRfgXlXzATum+sHcbL8W2bi7z5wh/iW8rkqcH5uMiPhoX8dfX+ivfBGudj4/WnD/w2piqvfhGxh+qngrNFIkL2UarJkvzJfUkDsvVYuJuB9kpbBHunK1eApWTpwvBlMqOHRdWviNf1FnBd/P6ifGHsfvRrvgtlwjWPq9eP+qXAIazE6DyHZUmYG2ntJ29uQRqqtJcOEBnzWKmTO/5d3zj26vRZZn83pL4BDB8ANYA+vVJ/+jTo7fKM6tIMyvXbDdkadZPUs93j+UDgrV46aqQiebX1/FtEV4mR7hlB6U/22lrVH55eUJ2xiq9kS+UJhoX2fnIXLw9vz5K2EHpJO7EDp6P2tlcp5EoYXM/eISZNcMjcR0j0bMx8sudBVgLfWhcGGgswZ3VQnaeGg8nL0dHSD4a97qcizEqY6ac2Bt3PzFFqEmwM6pfT407L96bgYlpL9XOQ3/s/g6o3Cn2rq9N6RPuHN3pyi9tF7Y28+rbpsPhkyCSPzuDgS4mJazRRF/9IcKg+IhvplGffHlWhOGrXyqqgX55qUZW5Sl5yLgA2MluCZroZ8jO0tHZoSr9oc7qLYEwMGo29UjsV/n1aNzrd4ysRku8E2E4pfiSMKB2imokrgD0jyg7aNxZAv2oPz4OWBuNrC9S4wJ2AqFpwE7gtT4lxlA76Cx83NvST7vXQnau6PnpdONEJf8+cbebjwM1o3kaiTI7of3U/CwG+rZ6vXCg8sc0nv9qSz5wQSYfpeme/O3oJcOOkLhzEgJhID6iP66aWfbOqnsnX8CmvD8If4vaKVx/qZmC0jkVx8jOLdUmaie+LWFzdXX5+HwpjJmS0Ljjiyvc6YdXgJr4tjMfGjWfaWSJMQADEQbwnc/c1UcGqHz2SKicTB6UkJ2dfIlQUzUuvi1qB3wEyZ+ejKJ0vLJxVwUIwzw6ywb6vgnZuPRxCzeK7pw/A/SPbbgQKypcAGoiOYeCOmv2EGxwC2ww5t0aG0VphomPfM4utInu+IA7tuz0i7LyrzJ1YmtnNNDvHh/Ewf6eIpvI/np2dUVN3OA8aof4CHABz/ds/C6uLiD5AGWEB+g3xqfGXnyPj+AjGFmfglA5D9DPGFSWwFABnYozH0FprgJ30u7J12xK/M/PR+VbrweXxUAH7CxpuiPiM6p2NFv7a6YYukMDHaWJ8CeK6FdudsuCawelv3qK7BwRrKX25g6Z6W/GY+NjYx6Ep4nbtcPai8fG1kCVr3OiMwT6ld0h0HfA2ga47Njo6MgalWYXI4snruDaJGCQjUug33LCmirN3VtHaZrwgTiHF8j+1phnhFA5FAGsAfTnQZV5pvge3TqreQYhkVKNdacxX+j4xGWDpINmpjHRuXEZ1r4R/jNs4Y6EHRsuKNgRCneeHiVs5uMxTFzGnX91ltVYb34ZXoz+++NiJCaI6W8XpA7KqMoPpY7mWEhgZDFqCgmbhMpExeeamoqzkHCEx8QFLtSOpZCg2gEf2VKoeSwizPSD85LpR6k0vayDWGZZpWmHtd9yEbDz7pi4gjprvwjQ56GCmQJY0zPL9nyauCCDNHFVdmygTMkX9uyjsy7SrwrWDBUvRKOYKVluXO4s0ikz05NU+RCJNHFRmiSzED84BcIwMT1Ve35+opk1egemXyxoHST5yMuR5CN4fby4hZkCvoDGWloKH56ERGpu9zBOfMS3ERtH/I0lyLjvLqk4zJRJ4E4DIhSEoT/2Ddwhpn/z9Za7ymQwcZ/o26aQ/NK+cB+JsvT5+ciOx2OXWR/zbxQedAew5r2n5Pchs8DW3nLoLDXRSSUeSLKJ57txWftAB2piZHWJjwhk563ZaNSlyP25x0xRVLx5pcMD9P8Oj8qfCxxAZm0ZtmYXoUTFlQPw+1CtVO5+pdvxRiPL8JGjJCR0hUeWYKa/lnVj+uNrf8yUITaFgS6yl++2ib5/b010PF+pOIys+dlZVZoxAn2UZt/4Fy16vZDPf8BIvOv+fqKzUDuGKpuRaEfN7OryBfsXzNaAC3t+/8S6AKyxDuL4KM2PdzB9RmWwtf6YpzdC4XstJJ/sl/PzNLGpFNhaad8aWetpgedHVHyUpsvEXfrqLNga16CmGVnMpl4FYPO4gto8SCT2SCVub11vbpBKXI6kF+XMcuogNjAi83LivgN2GjWouBEha9MRH4SBwtNEVyMROiVKAz1zQiOR3J2hxhLUWZEvq7MA+s+jZE5VKsCFEumgNycTfzyQjVuSZDBNfCGSFgQMRDZn9iXZHMfEBSqHV0KKy7qg5k/xpvuOypevl99W4OO6zawFdo+Ij2xN+qW9Q3zkx4K1AaIv3Ji+E9bIYGD3CLjAI4tA2Qk7yySzZokNvmnceRyXuGN0kDIwTqovaNxDgD6NrCJGFrlHtsYV1LncuCAMUQVroFOg4gjvD0zYcUd+W3BNsl+ocR9oZHHj7gq2AJD9jSvpACTJf9FsbeD5ttcPhRdDdAoaGqW/Q/bOppxZy+eGThFhYLbG5hTzBTQWhRfcWd5JoPIjdJBp3JyiO0pI6NohWOORxeEhoUPz83MozWnILD9Q2T4SXTvrt0zOoxyJRJUfHQ5AHLggohs5NVTsqOwntgZciIDuSHPKfaBbpSlcnr/NxiZ1Fp4fDi8gO+Aj+6A7fglrkEEEa0qnSKosiCtbGtoh0W0amuiU/rYIn6bSlNadhLVtyKzNQRnXRHyU/ggmrufOIoN2FafZFElo9XpBxmlyGPTJeTSg35pXoA9cQO18k3VXdJDBs7rQnQWhUiaVSHSKYW1xMaxrZxpk00joPptTJKGRndcZLSQElMTt7ycLiTxA33zcVPJW2b5OwmD7tux9cfj1RcgsHrltuTKQXJYk+nfFMr8cuDMks9j2tWTW/pQE/QHzS24kxus1v3IAbjk72thEY50+1O7p2wolQotbUoRmViLngw4Akk/+iLb0UTts+5I/AiqL0iSRKABrqE2yAMDW0mcEDMCdg2Li7pYbl3UKa9yzBSWzhgc6GkssuOigMnvu1wB9JP+iCbZWBWFA5SfI0o9J98hiU8fBueSOUO6UpuLM9E1pDviyJZLQ+Vw2CwmN5GNkpci/2CcmLkqUHU3FwfT/QGUX1Bx/uPdY5pRwQeUbCWvu1t2w/SLJoHglLis/7neFn9+T1p1VmlLj7u2UDRN3cXcEEQbzcTHRF9hb06Vv89au3y0JbaPKO7TwAJsS5Gz+BWuMmiHqLNAdLk0namohkb2svYnzs4asTfCRiuysf3FZe2nOonFbbE7VJv2COksbp0Q2O+0s107jRNaOZd1FeV+zbDFxaFyLiYuNX/VxwXdaU8p/UY2L2uHnf312sg2unUfmsjSy2FUmmYXXo3SWRSoN3AlZKwM3X9aGOwNsSk3Eh9qxSCWTh9Ui2NpOHB9XT1wSobxuAtmEhkZprnmHNS4q34CycIhQWqikMdG1SlSusnEe/+EqiyFb2dm4n4Q7xGXB9PFtCfQTCvTl61Xyj4XNVjaNSzNlWKI7JHS2IV9vwgveB8mJbjc2IUJnYlqnDLpH8vWaL9AiVMqsnNyWaT5ye0gSncNnHLbvscvrDRkUQwuV2y+pEnlPfEmoadwjs2i92GCdspRWGwOIRGFq0+Ky4c4HVJxfhUdnuegUwxeq0mAoChl/VXlrJ4TKs+SPsA7aWvEowrC0aIc1S+PSPuUmD50ijKc/BAxy42Gebyx9ZEc5AGamvDVnhLGVeR9U0mtoPN9suQ9IJcp1E5j++iqEBG2byB/ZRWMx0Y8JWlVGlOn+H7UzsCyjNfTuTiy2zcajICVhGjegbGUHH1nsuDqDA+aUsJi+5iMUn5N/ROHJnAqQM7gjncG/dIpweHfm42KiI/ztQ+lP6y4JvjAtl/S8ShRrdio+22yAKnv0xqPcV6tEdNawzJJUWZtTIhlmU/xQyyzL0+8BF6CDTGnazCl2Hp1MXMj4O/mS9vTJ2JQqEajJm1CEX6PS/MW37f3ljwgySApcO4TKqB1o6CNpnGr7JU9b7hUjJBymtf62S+IPDV3quNKpQap8KW1ZfFsxB64sHQYzEpd518cjUZlfFpclmWV2fY1Ta2Mg/l9sDSPxgztLN9aYcXcEZ6d1eaE6i7isnrgD5peW6Lv+idhw8oUz+8Adk3y6T2mm2VVG8veJDOb1njh7KrNjsSnBdMqIUPLW2iHlrbnu+sySntlUaT+xCzYFhS7YYTglC8AYGMMXEgPG5rCKy7aEPT4tWnfjccwsdBaVPnQQnacEMVMO9IGHPXzHorLiz9rRdMdyrY05BbojsxOQCw8fSkdEKb7y7kx27M5j2bFoPXscAGW9hhZ/s7VFAv2uvq6BhK7j9ewM0h5Xg3KGGgtcUxAqJw8OWMZR9hVVXlbeGn9c7bm7XEgYkSgUYUDpK/9lANacFxL/2GZpZ5OyT94aU+WqPJ0ypVnnEwYyp56sJb0eWTI5wip9NbM8I+uKMNBIJOtuQpemYfpElc0NAFQcZopQM+uKz1+08+i+RV/96UUGTfGJx+oY44JweHdput5J8QUGa2iyXzbX5YHHIpVmghYeNLJ2NmIIv7kx0ofGDXa/wqLTRnbYl33xu3hrGRdTHDNlGBfEv01xmXxt+3aI7uRzPNAlmzoyNwBCHwEMCwk700fyu5+fpHERfoYvJAxfYKKfE7ZFLrLjeiEht+h235SPd/qrtjVxU7gu6WlPbHeVHyQZNFzWbumTkAAuCKkk7EKCyabVWR7aSLirONqnaBUnJN9ROsjBZY3nTmdxbXYAJqaVAzDsjwh9QKKzI7dlLsYmcGdjQo+sASGBgS7+dXukDr/2bh1cdqDy/c5tloMwOFaVA2xNdpadDPLG4EKcp8OH6m6Ns8PW4PLG+u/Pzzc+LonQlqodqeIqdi5rUDMlnl24rJu9I0+bFJftDG8khOPGwNTOH9ssGonMpnimsLemrTXhMDDs3tq/LiS0527JLNpm6dr8j9LkZdmvPPBwLtGZLwhDGGzGphM1dWmqEwYGZduaWDmDwjzfYX6Z7EhciKTSZ1pCo3aUtzZqFqGQQeIPHeTG9O+tkaU897TaZqGxhDLFh13rv6iyvfKRHV35LLPAZXklIc/iFBWXa2gqTes46B++qfi4hMg9G96E2p5PNwBHc7zwoD0xlWaEb5Wp8gOEmrOBV1Gv19BZj97qfY/YoDwOGmD6bqdNtonLjSus2unyvewHrRLNx7W26HYuq5f0dnNKrNpvmw4PSAdBqHi9wJ0lyk7PHH5Z5pTdWyPUpDW0kKa7WVXaZxbIYIgvJKy7MtW4oZ41U14JNX0T4pfu4txL387WbKipuazzvkPITej/4lrTcZBbdmRyBN826S36ps+5pNdkE8kHao6oPbHDW9M6RQw+35zFEWGYDUxPTykHYHN0hExxLs0Z5a3p8J7KiCgrU9wZf9C6s42sP3SKAOi3Wy11diePBplsIvmt67w6OHVwWbWkN7Aj+YjQQkWrRDus2a073nJLZzDXucq0am/Plj+CyhfKGnTykSPyRxI2f6QvfwXQCfB5Cp0YoDQnftkZ/OXGEmaomNr560JCX/VN7vjUTaLMzqeSWXh+XeKOE9YcjWu/SXQam/rqTrBEN2voIP/KQK8M6F72Uf7K4LP0bbuQGEz+39usQV8WKpErP0Bn+jI7snHZN222PzJCevps7/A57oAprq76/rJfrLM1YU42yRTHRL/O5a7IW4MIBWpqquw0p/TBqXWTOD4mUPq/a8p/GXIYJNlsF27yxGUJ1tKN0xN2BiXoW/saIYWK9mUdQsXh6RuNq0xrosoyPMFOAzKLVhIPVftCxXGxCTo1M7UXBVsbOsBwHPWJqvq4Pb7qc5b+wCbUSr453oGQ8MrSEXS9Qzoo2FK31hASj4SaIzYy+Oe5LOkU6ZuK0D+tQesc10kGIaHBF+TrpUgUpUHCANA3hEGeNk14AWtAzR8IiaU5/oEKkcFxfv24fH1f/Ay4U7XjoyclQp3hVeUj+aRxGZQ9nlEjoUWH2Jq166v+GH+E7mX1NktXfuXuuiwPMOQ9a4pgjQ0GwVd9frIAoqPSPZJ0is7uNKw99OnqTuKO28JjD+GFC6yZxjXmVJgmrjwm1ndrg76p+JPpZ6K8yJUi1F47xDVl7ej7ERD9N2FONofvRySXxUjUe2Jt+9qExFxSCQmBznXjsnZPn2ZKmxwAluhvSD5tKu9u9VncFf36SChnc1Fag3g+ofIg2XT4svbfSFjmlEDp0+WXOX/Jmesa4zw6RKi8zDIOgFNm2X+DkTPW3bG8COXk52LSNzW/kdD7GnO8I0agg1as653hHzHQHldtQq27Nfa+1O0RnTZdRoS5bbLW0LbLrIFfkICJKzbFv5HIyV8fPZGxKf7rFhoTd1LCmvu+Rv+IQciPi+xYhMGpEod0kP0Q3SodMRD/2QKGIT6if8TggponQSEvv3iiyxuDdcpO74tXleisJp+n+Jjpj3bV60129JqYjgZV9pX5xUcAAzcANtfa7jw6jokLgn8Zd8ULFXNNbHcYLLZ2Epo/+tv2Ff+xMjhv2kCfcCfnuNi0boPElKRTXvXDO74mlj+MUxraZorbfwBjN8WpdISuHRc6xVx2w/W6ZtC/6JDMch2J6j7lktdBoZA0NrenEF4eeCzZVRyhpnC/JqZ7Vq3ibL8ycBESKnxMbA/98M7l2tcxshy+qRlZ4v/aO7OuKq4tCr/PfxEjSowY5NoBNtjESGMXosYoEsWIIiKgxp7ffmuutds6dQCt+XTHfYxJ9ij3qdp7NXPNr30lNuHUT4cPp4nWz6YfCcEga1/Njbtqp+bf9WAcOgoYdqfczTV3vju++Qd9+aSuOe7DTbyycIiHfmjSN2mWheJ2Z91swimb2Wx2hzObD+K7k2T6lUICdTgVFBI/PI8f7kCzLF7o7WYZysG7Mh458fnThw/voyKUk2trYUbicYc2aO06SuXXbkloiNZ8ovWdJ6GvLAnlPG6TZlnD5o0N3lnRnTd6XdismvRROVUPMTTLI3U8qiyxVvU1bz4PfW+WlbvDEY9Tv9uxg5b2aIjmMZ874djh8q8ZKjfLzz1bfrqE/O5w9iv2ibtOZTuUc6zp9Qu/0B89eoiO6lRWZlVZYjzWujcfpXSq69zpEhN3TSWiUO8krTVf/c1UeazqptWpmRqhzeZgeOXxUvnh8tC3VqINVVoS+tSmlW06qLnQsX7Hpq1v3lixoc2VNMzdFge1BnKrC52iQWaJNis+qFsrJkj2mmg9dBEMxdvHJoe5q2BziGIztYkXm79aCKcmdkuzuqO1eOOub/2xuOHdrOcdj1+2m3xi9uzQaI3LIyShSeiePtyF52XNfc+JVpSqvuZKfPUyzvV9tHnipZCiW5bIblasfbVzXEQFRvPh7tFFL5RT6dhZ9En3Jh7Bs47Cad0nrssvpZI7dZuazUeKlZsb15v0azHHdcXmecuDijvFyr70ARjhJL0Hg02a1e4Tl6XBok/MG3c1inesI2Fi4tMWjzRP/wvmrHBqP24onHon1L6sfWkAPJpCDKe6dGuWZk0eyFncW79xeS4c4G9bFKdQ5dAvFuzY5KlZao+KAoPVZcOp+SU8vZ0L2MxJqE3GhcG42KociGWHqe4QssTTbEP7lcj5ms1QON2pHr/19Iw1l0LR+gJyCaC4cUfPV8Gg12XTNLQ1y9pyWRQtg2Lqsblx0wxGUT3qksty+fX1l8hy3L+rAZhU2Ix3SkfpzjY/vJqwSD8P5Pqh/9JNJD6t7HTV3Ivd4W/rm4Pqx61HyzrPneLYcdWdW2D8g7A7aYiBu5MmSLoTiTKLs0n6ZIHB6tEDm1Bp4p0mYKBBiIVTVsCgEP3cubO3bYLkZDWzWbSJMZDGtdS+/97/826T475wOe4Q1d2JuZtIJYBqFr1b7VvOZoVDOTVC0e4TZ7Hy8Npac2X5hZ5jzWCBUd7o+cPd40oMJg/hw8LAMPfH1qB+0NHXX9bgh4XqyzLt0Yf37969Dd41B5vln6+m+kjnvK8F+ssYdiWWgtN04xaz4jtuYxA7leVsVnsmtHw162HutPyH8aBVPuaiwSZgsEPfIv0lKyu/8lj2mc0Tx7qsFTDO/TmdhxhyGxrDx4P2klRSwsCybHPmPzh/FmeneaOHoUrOiucKQHHj7paEelkWQ0Y8KItLMxhNjps3fzAe+Xl9bfQH7D2DUVUeQx93sAIAXirD5neiuoY1/aD2DT4D16ryCyuDIc0qi+671NyffUmxpiWJYWyQJX0sxOkmG8iNr/4QcVB7CsB2xzZnBcOmrYOwzEWD55K0qTkXYmGTTfpsY4AkkSgbuZ2C07JPTF2ZRVNR1EfRYJdYecjIaRnutKIpVNWj/cSyx7stKrBLXdZlcVPu7POfWRu2nvXCpmmPaFHx6dNHfrhvj2N7a3TsaJpQab6szlblfNd8TU6hZ4/+hg4Jg2WJ5fKe49bVo3ajFQM3urehk/xl6Lnw9EB1LmBQjlvM7wyMuqeR02nGI0yDQsNjBEX9ZejjV+M7g/EI9SMXEXp9nMFIh/4hBoMvaC5zwNtNKUWvGq3ZnaX5bVE6eKShyjCuvHsiwUM5JxJYz2OJQbdmtbVyorUoMFSiwarAgPxlPWDHI05DU3A6b21oCxg8S/Snp0Ji4ddak/h1GqXy61gxi16U7vYwCLEs7iSGtiqtwnD0DR3fuLzduMX4TuvNT7NZlx4N+3E92Jzku/NlsjkXLNYMN26qj0QLjPaXtWsb2k/NK4ej6ZSHsjhhEonNsTAr3i0OKt+dOJtVVXfG5zE2TBzky7PX1yFtGlS/YIg4KNgYmJjY2k2fbCbUI3EWrcvpIH5YqHyVYoqeN79Lal1N0tuxtr29Ba9Orfn6KymH7h7UrySVtXIKw1R9LJymblbHFEDRqVy+NPPwDrqCzXYweIoCjF2b9Nt3kHuJ1eBd2PzyVO7WlUXHL6zlhkrHGEBXGzqGO5xo9VNzJDgNhurRsf8M6lNSjru7eKfJcRGnDK7OdxmEVBOtna9mfHpcD7uTmvSLQ4Rf0wezwKND8ggf+I1a6OLVbzv7FHVZa3i0LnScyQYkWfPY5LiP03zNBvvEi2nYejbPSJSWXAgeFfHHzdFaMX1UKjaLSfpKk4hUeWR1anpy8ky0Agy2SmWzrCi/FEVrxgtf2M1qT1t/o/ArSJvQXIk2eGfmMqvmwuDdLMtxWZy6ffsWW4mMZTm+M8T8BUNS9FY4lWVx99/lqnI5HYRL9x6G8SCfPpqgjWQ5HpQ3v1suG84FpC+rCRhSltiRhPqr2Tx9p+qOaVZHsBlld887v6ygK5s/EaaD3IEUdqmc3gn9oMr3qJTFDfNhpEml5SkoRzwq+UsTiucuNzUGgxOtpdoXnfFOrrlPXEvCL/M94qn59XM2CImytcPglEGz+2mI4V5pEDJXBoPnvI/rH+54u3QXLTDcyXDzWFm1rmT6TTyymA7lQRuDRdixOe5XYhCWmYGqd0LfjUWrvoNenPpnxaxx7Fwwd5Y1nw66jhCtXfmL1Skr+97yPKj6cfnbngnHWixavz684f6s/LCaNMtKg1Z0v+v1F283mcnD4zT6dW/yJrtZvryrXypfoo+0wEix8hGL9JO5jBuoNsfaH9Hsrmh4XLjDkdDkIfEbrDr180/JCGDH67Lh3Bl9fTQVvyoXyTeukFh/afO4zdPDRzyY5J6dLuS46dAfmearma0AJ8I4cWwHxZFQhOEpzqJ7XZb+r6ZPMTFx8+5YmhXEQcVkWQwGw2+L9OPa7q94TZ/lndd/xolZjn4xGDSJgRcwzobpI27+uNXckatTX09WrcqgFF/1eCRoj2x3OpZ/tIS7VmHouBLNwaMwSnx7tLyyvh78MRio+sDsXazfCeoaa1U+spaBHwzTroXOXW57d/IQQ1k9OkqnQf64oTplV2LyN3nFRmvKcS+ZRWiy5KJcdjwkiTyUMcU8qGpzN/GIdTw4ZfCJAzDu7HPf7hS618Zh66s0OLVXp/ltEToeEzfS8NT5y8M+3NpAdcmHm0z4FWazOh//+qkobZpl5ZHhjieJ7mqdPDabYJCaRARRou9OrL+s2uhXLu/Uw01MEuvf9oevXxHMd5mobEURAIPNVNP/a7Myf6EG4JrFIxdtsiw6fiGIlYd8WSaLS55WBz/bfE00wXzFc8GXn3+MKlrjWGJhEFIJPKzRmmVxDAbTuUDR4L/LJuWmcTObcavmZNjcKZaE3s8zoaevx/maqBQf8eX59MctzcpefUk6xZr74KnJ5QtXKAaDHsrSFhr+bh72Y82HuY+fsvrLwPKmPeJsVvPm/+GWXEEu2zw9UrwzdYvxTtSnZFkcfY8YKudOpRWtW+fCezDY9JYEZ78YyxYDuefOTk0lOzf/skIkfiEYGXqb+OftTYym4ancCfWDoT4Xou/RBZv3paTSfZstzWriBZitdQzFP4xHh9OcZj31mj51a2bJtZXfnfTq3KNo8FzUp9i7YwFDyKHTnZWurGDgUS9v87hb6Fifh37H8haPdC1v4h2sPQ81/aD29TurFHg0d0oKp1gfaQ7lJG26dvEq3/wmGHRDd/64MQndOMRg83BSYJjq7v794tSk+UuYzfozVneaNKutCG02P9g8hlD87ZvxrdJeNhUYGGu+ia8OgsmmVa0fzdw1W2saAfjUI40Akj/rgTPRQJV2a9ydDV+eT880K82ENtFaMiyja7YbloUud3El+rjyjNXW7NRs8hSEV397PI+cponZgeXDh/ukw9MK18Kh333jjrv1zk9rh7uvrOfepF99Zk6DYXcK5+ObtvzYtaAf+dFH0ZM85Yi1oXOB4fH7LBpM6/PdsWZcMnSP00fupp+vxPpGhI8fMZx68SLLcT8txWAzuOmvWKyZfRKZhFYaANj6+5ByP/Y2dPP02QfAFBI5zZp5MKD29eGpy4c6vqyw+e1o6h02uDuLWVLJ0t3fdmrauTPZvtDdTf9AdtgI3jLY8Mcf8Vd/+XMMxcPmF0MM2fHL7O5PnpgIFp4XmULj0MjMgJS7urPYSnz0KIAk1nkl3o4VgDJURhErN0nu8Fh2O9o8Nil01Yb2ed/f4QHDfL4Sc112sStPiSn6+19YlqXqzovW6IhlO0/lrt/WRkJDIoH2qWzxyMCPm/ziX3Zu/s0/TiOsHzzFz4eAoYnWPgd/kyTwqCP9ZFHBC/3GjSbNClfu36EofjZ56d0YHu6MheULbZCnWUsP6QudD4Zo+j0Yy87aqzl29MiR4Gpt+g46Daay8utkIuGheHXu3F5ty/TdB8DPBb6aCCAJjpAkC4ycZvmHGy3L8zR0SxvUBPp4EpXoA+2mS7/FdpOBHkK7aSLZGKzZfE28ceHSqSZaC+64T1bT43fMYFxJM5t26H/xK4t3CizST5eK293TCMA/3LXoXTM/675HyyGamr5rta9wajZXFgburBDLOssgnJqR0NIca7b5L8LuFL8tih93PuRBYz+HcGoqyHHP2J3yNm3+qB/6VSSOOhT3FL0Jpy4U/iYeDOZobbJcPsYLaAcMHzyHzr5HqQLwyGYkChfJ6wu7pVnxzhp9sboaf1ymWTEJjcs/W87L87dF+ePOhQmV8Gqa1NqTUL9xTZMYzO6+LC8tUZ4STKFu45mHU7MDN+51ryrbuXAxzPvmG9ddswvAjKVZ/mU92EqmVqvx1Q+ME9/825ni4WnWkUBoOe+zWWH3qzTOAob3me5jj3/r1s1A94myOB5rZgq1wDQrNlSOdMcjPxV8nObKClXlrYzHuWXutSYafBgt0T2NiwMwhUzf3530ZW1vb2VCiycSyJrH9YTfWVjN4qDKF3o2Pj3DHStshlD2lHezbBY9Oh/Hd2fpw/AJEn/6e1NFho7cS/RzJxa/otlde4IkbP4dqyonQ/cndBpsVY88WvNYtjPN8tpX6GY98d/2wRb+cn8T0x5Z9Yiv/pUrka1kfvQL6Ups3ykTsQ29SdHgSDzWnq74+g+7Dn27si4tzZx3b1+/0CciWulXdFaP/EqkKbd76TFUXnIyVGeatcRuFh//THj1j4fyjm/+j47lih6eYfQrKDZXPtaTZRiwIDWL0HNmOnWjVoqXvkQ+vsPyS+hyoz259tfJ5sfd+Vp+Zs17ujPwJ6/Snzy5PMDN6qSKtf7/6lyIH5alWZmtFG2t042elx9d2Gt5xFPZ0rgvcf28PMu+M0+LY20yFzbj0+9ccdFgk6i8ncrWO+XjPzxgRfFPsXS3sJmffqY8NScxcff9yWO/x915afHI5R9bX5YnoUefesBwkB+uPf2ihcrbv8+/noVNqDy/k/+Pne4N9j+t/l31D9jrx93v8uhe/9uXx7c8/m7L42Pv3fHl0X938l+t5+74H6D/7vifoP/u+J+g/+748ui/O748+u+OL4/+u1N8a/12x/8B/XfH/xT9dycs1H93fHn03x3/D7Hn4xNnOWz51UtpeQyuPzeytXn1h2/dfOz38Zvlrx7oevrxcWoS2c2yNC4Fm+9/+XesuHFfXJnY3+ZDc6zxryY51lxZ1/NYezr65K05DfannNJbBArKKVuJUFBOCTmFgnKa06yelFNKHqGgnJI1AAXllB0DKCinhJxCQTn1bpaAckoFAxSU02EWGN9MOSXkFArKKd98KCinNBSDgnLKzYeCcrqn0+B+KaeUxUFBOY1pVm/KKSGnUFBOfTZLQDnlNDQUlNMoGuxNOe2czfoeymk0dO9NOX1vFhgCymmczepNOaXqDgrKKT8sKCinlDxCQTlNFhh9Kae80KGgnBJyCgXllFVlKCinPJShoJzy2IGCckp3Figop26BIaCc0qICCspptMDoTTmlKRQUlFMeylBQTvn0UFBOKW2CgnLKVwcKyum/YTarN+WUryYUlNMrNpsloJwGp8H+lFMeO1BQTg/Us1nfTznlqQkF5ZQ3IhSUU5vNUlBOuflQUE45ZAAF5XQfhu77o5zyRoSCckrIKRSUU0JOoaCcUj8CBeWUgT4UlFMO0kNBOeXTQ0E5ZRMdCspp6TTYi3JK1R0UlFO+mlBQToMFRn/KqYkGFZRT+oNAQTnlqwkF5ZQ2A1BQTjOeuCflNBi696ecmqG7gnLKDwsKyikhp1BQTmm3BgXllE8PBeWUoTIUlFOSGKCgnJoFhoJyyg8LCsopIadQUE4JOYWCctrlNPhdlNNv52YNoZxyMA4Kyik/LCgopzabpaCcUjkFBeU0c7N6Uk5p4QkF5ZTxAhSU0z24WfunnJL6BQXlNIkG+1JOOagPBeWU08pQUE45VAkF5ZQ5KBSUUz49FJRTVpWhoJzyToGCckrIKRSUU5bWoKCc8tWEgnJqokEF5ZTxAhSU05Bm9aecslMJBeWUiQQUlFPGI1BQTpMFRl/KKSGnUFBOCTmFgnLK5aGgnLI+AgXllPEIFJRTjqJDQTllsAYF5dREgwrKKTcfCsopoykoKKczhicWUE6joXtvyimXh4JyOmPcLAHllL8tFJRT00MqKKfmNKignE55mtWfclpws/pRTueyBUY/yuly22nweymnhJxCQTnl5kBBOaUGAArKKfu4UFBOWbqDgnLKYA0KyinDHSgopzw1oaCcRkP33pTT2M3qTTml4ToUlFPKU6CgnOZuVk/KKesXUFBO3WlQQDllvAAF5ZRPDwXllGkQFJRT72YJKKdhNqs/5ZRed1BQTgk5hYJyylcHCsop28RQUE55akJBOd0xbpaAcspDGQrKKaVNUFBO+fRQUE6proGCckrIKRSUUx47UFBO+eZDQTnlnQIF5ZSQUygop8zQoaCcDulmfTvllGVZKCinjEegoJzSRRIKyinzFCgop+xIQEE5pagPCsopxTtQUE4Zj0BBOWWSCAXllBUAKCinhJxCQTmlqA8Kyik3HwrKKcMdKCinbENDQTllPAIF5ZT1Cygop7Rbg4JyammWgnJKyCkUlFOfzRJQThnuQEE5dTyxgHLK5aGgnPJCh4JySuEXFJRTdrmhoJwyHoGCckrIKRSUU746UFBOeadAQTnlqQkF5dQsMBSUU575UFBOi25WP8rpIRMNCiinjKagoJzyXICCcsqqMhSUU/ZroKCcsuEBBeWUxw4UlFO+OlBQTpmhQ0E5NUN3BeWUryYUlFPmKVBQTgk5hYJyyiQRCsopI3EoKKeMpqCgnFo3S0E5ZQ4KBeWUoj4oKKdzMc3qSzlNhu59KacMlaGgnLIRCgXllPoRKCingZvVn3LKFBoKyilnp6CgnPLpoaCcsgIABeWUHQMoKKcmGlRQTvn0UFBO+dtCQTnl5kBBOTULDAXltJ1mfTfllBUAKCinPJShoJy6BYaAcmp4YgXllB8WFJRTPj0UlNNiNqsf5dREgwrKKcu+UFBOCTmFgnKauVk9KacsMEBBOeWdAgXlNKRZ/SmnBMxAQTllrAkF5ZQKCSgop2xDQ0E5ZekOCsqpzWYpKKeEnEJBOaWCAQrKKS90KCinNpuloJyuR0P3vpRTLg8F5ZTSJigopyU3qxfltMAT96OccnkoKKfsVEJBOY2zWb0pp26BIaCccnkoKKdjJhoUUE4vF92sXpRTflhQUE6Nm6WgnHJzoKCc8syHgnLK+gUUlFNCTqGgnNKOHgrKKYcMoKCc8umhoJyypA8F5TRYYPSnnPLKgoJyyngECsop4wUoKKeEnEJBOeWpCQXllJBTKCin/LCgoJyyLAsF5ZR3ChSUU/62UFBOGe5AQTnlkAEUlNNogdGbcspTEwrK6fOQZvWmnAZD9/6UU7KJoKCcsjgFBeWUOS4UlNPkVd+XcsrfFgrKKYtTUFBO7xqeWEA5JcwQCsrpQUuzBJRT0negoJyy4QEF5dS7WQLKKTcHCsopnx4Kyik3HwrKKYM1KCinhJxCQTllBQAKyumcOQ0KKKcMd6CgnDLWhIJyyuoOFJRTzopDQTllVRkKyimXh4JySsgpFJRTN3QXUE4pCIWCckqXBCgopzyUoaCc8s2HgnJ6LXKz+lJOWVWGgnIaRYO9KadcHgrKKZeHgnJKyCkUlNMNM3QXUE43rJsloJweGnFuVm/KKUNlKCinvBGhoJxy86GgnPK3hYJyak6DCsopD2UoKKeeZgkopwFP3J9yyt8WCsrpE+9m9aecPvQ0qz/llIE+FJRTXllQUE7520JBOeWHBQXllPECFJTTgTTreymn/G2hoJwySYSCcvosGrr3pZxOWZoloJxyeSgopyYaVFBOeWpCQTm1bpaCcsoLHQrKKTcHCsopHTagoJyyUwkF5ZSvDhSUU5/NElBO24bu3005pfoFCsppxc3qQznl5kBBOeXyUFBO2amEgnJKyCkUlFPDEysop/wPoaCc8t9BQTlNcCkFxxMKymkbmdqLVAkNDtByEQ3HEwrKaUamCjieUFBOQ6dGw/GEgnJq35qCcvp/PLECT7xPymkHnvj7KKf7xhPvRTnljQgF5fR/Ek/8dBT4L9wxn4vN6QAA'));
var byteString = "";
for (var i = 0; i < byteArray.length; i++) byteString += String.fromCharCode(byteArray[i]);
document.querySelector("code").textContent = decodeURIComponent(escape(byteString));
<script src="https://cdn.rawgit.com/nodeca/pako/master/dist/pako.min.js"></script>
<pre><code></code></pre>

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

Please note that Community Wiki is not a rep waiver so there is no real need for you to have marked it as such. – MD XF – 2017-06-14T02:54:01.130

Unless my clipboard is playing tricks on me, your snippet shows only 46485 characters. – Dennis – 2017-06-25T22:29:35.807

@Dennis Snippet is compressed – ATaco – 2017-06-25T22:30:59.133

Yes. I copied the output of the Stack Snippet. Copy-pasting from the original website works fine btw. – Dennis – 2017-06-25T22:32:01.120

The problem is most likely because of whitespace and/or HTML escapes. .html won't work properly for a div. – Dennis – 2017-06-25T22:37:16.787

@Dennis probably I'll look into it when I get to a computer – ATaco – 2017-06-25T22:38:02.670

Took the liberty to make the output copy-pastable. According to the result on TIO, you need to count a trailing newline though. – Dennis – 2017-06-25T22:56:03.783

3

Haystack, 7 bytes

Yay, my first quine!

"34c,o|

Try it online!

Explanation

This is a standard 2D quine.

"           starts to push a string
34c,o|      part of the string
"           it wraps around and go to the beginning of this line thus pushing the string
34          push this number
c           output as character (ie outputs ")
,           discard this value
o           output the top of stack (ie 34c,o|)
|           end program

user41805

Posted 2011-01-28T00:34:05.293

Reputation: 16 320

3

Actually, 4 bytes

0
0

Note the trailing linefeed. Try it online!

This exploits a potential flaw in our definition of proper quine:

It must be possible to identify a section of the program which encodes a different part of the program. ("Different" meaning that the two parts appear in different positions.)

Furthermore, a quine must not access its own source, directly or indirectly.

The stack of Actually is printed backwards, so the first 0 encodes the second 0, and vice versa.

This can be verified empirically; the program

1
2

prints

2
1

Try it online!

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

3

Logicode, 1368 1241 1096 1086 bytes

var a=000101011000111101001111001011000110100000111000001010001100101010100101011010111110110001111011111101110110010001000001100101010110101111101000000010100011001010111100010101111001010111110011110001010111100101011111001111100111100010101111001010111110011111001111100111100010101111001010111110011111001111100111110011110001010111100101011111001111100111110011111001111100111100010101111001010111110011111001111100111110011111001111100111100010100101010111110000010100011001010111110011111001111100111110011111001111100111110010100101011111100101000101011011111110101111010001000001110000010100001100010110001011000101100000110001011000101100000110001011000101100000110000011000001100000110001011000101100010110001011000001100000110001011000001100000110001011000001100000110000011000001100000110001011000101100000110000011000001100000110001011000001100010110001011000101100010110000011000101010010101011110000101010111110000010100011000010101001
circ p(e)->cond e->@(e<+e><+e>><+e>>><+e>>>><+e>>>>><+e>>>>>><)+p(e>>>>>>>)/e
out p(111011011000011110010010000011000010111101)+a+p(a)

Try it online

Explanation

This is pretty simple as far as Quines go. The first line of the program assigns a very long list of ones and zeros to a variable called a this is the binary representation of the last two lines of the program with each character represented by 7 bits.

Then I define a function that takes in a binary string and returns it as a ASCII string.

This works pretty simply:

circ p(e)->                                  #Function header
cond e->                                     #If e is non empty
@(e<+e><+e>><+e>>><+e>>>><+e>>>>><+e>>>>>><) #return the ASCII character made by the first 7 bit
+                                            #plus
p(e>>>>>>>)                                  #p of the rest of the string
/                                            #otherwise
e                                            #return e (i.e. the empty string)

Then on the last line we print var a= the binary string and the ASCII representation of the binary string.

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

3

Threead, 24 bytes

">34co<o>o<o">34co<o>o<o

Try it online!

I didn't think to do it like this until I saw Riley's answer. I have no intention to self-award the bounty, so this is non-competitive for it.

Explanation

">34co<o>o<o">34co<o>o<o
">34co<o>o<o"               # Encodes the right half of the program as a string, in the 1st buffer.
             >              # Move to the 2nd buffer.
              34c           # Put the string represented by ascii 34 (") in the second buffer.
                 o          # Write it to STDOUT
                  <o        # Move to the 1st buffer, Write the contents of the string to STDOUT.
                    >o      # Move back to the 2nd Buffer, write it.
                      <o    # Move back to the 1st Buffer, write it.

Originally... 129 Bytes...

My plan was to use:

"\x0E\x0E\x0E78g\x0EBv$/s@$@c8$$$$$vB\x0Ep$/c6Bb_$f$vgs@$/Bba\x0E$$$c5$$$$$1c5$$$$p"

34c
>r +o< <_4     r>
l +_2>^[ b rco< +>^]
   _1     -_1    l

where \x0E is the literal SOH.

Try it online!

The string is simply all the commands after it, but with a byte value 4 higher. This was because I can't store a " or a \ in the string, without it getting meta. The rest of the script, acts kind of like my other solution, however manually iterates through the string, printing each character -4.

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

2"I have no intention to self-award the bounty." You can't. – Martin Ender – 2017-01-13T09:10:43.183

4The README on github doesn't seem to mention that you can push string literals. – Riley – 2017-01-13T14:58:08.177

@Riley True, but you can figure that out by looking at the Threead "Hello, World!" program. – mbomb007 – 2017-01-13T21:56:01.230

Question, how does string multiplication work? I was trying to get it to work on TIO (to solve your bounty), and I couldn't figure it out. – mbomb007 – 2017-01-13T22:00:46.580

1

@mbomb007 Hopefully this will help you out. And Riley sorry about that, the readme was kind of poorly written.

– ATaco – 2017-01-14T04:41:28.710

3

Befunge-93, 17 bytes

Thanks to James Holderness for pointing out that this relies on nonstandard interpreter behavior

Slightly late to the party, but here goes!

<@,*2+98_,#! #:<"

Try it here, but you have to copy-paste the code. The program relies on nonstandard interpreter behavior, so it'll print a bunch of leading spaces on TIO. Oops. My bad.

<: sets the program direction to "left"; instruction pointer wraps around

": toggles string mode (pushes ascii value of every character until next ", which it encounters only when it wraps around)

(at this point, it pushes every character to the stack & wraps around. This is where it relies on nonstandard behavior - TIO and the reference interpreter would push a bunch of spaces to the stack)

:<: sets the instruction pointer direction to "left" and duplicates top of stack

! #: negates the value at the top (important because of the upcoming _); # skips the next character

_,#: checks the value at the top of the stack & pops it: prints the ascii value as a character of the new top and sets the direction of the instruction pointer to right if checked character was 0; else sets the direction of the instruction pointer to left

@,*2+98: prints the " at the end of the program and quits.

osuka_

Posted 2011-01-28T00:34:05.293

Reputation: 391

3

DipDup, 6 bytes

[_:]_:

Try it online!

Explanation

[_:]        push this list
    _       duplicate
     :      cons

alephalpha

Posted 2011-01-28T00:34:05.293

Reputation: 23 988

3

><>, 9 bytes

":1-or>o#

Try it online! Exits with an error. Since the top answer reads from its source code, I present this program.

":1-or>o#
"........   capture these characters
 :          duplicate last character (`#`)
  1-        decrement it (`"`)
    o       output it
     r      reverse the stack
      > #   loop inner
       o    output

The # is a very repulsive mirror--anything that touches it will go the other way. In this case, it is functionally the same as <.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2# is the same as #! – Christopher – 2017-05-21T12:30:36.217

No problem. I figured that something was up :P – Christopher – 2017-05-21T18:39:07.313

I like the trick of decrementing #. +1 – Esolanging Fruit – 2017-06-01T15:42:43.433

3

Klein, 11 + 6 = 17 bytes

Martin Ender has made another Quine here

+6 from the 000 topology and the -A flag, (also works in the 001 topology)

<3+@+3<"

Try it online!

Explanation

Like described in my earlier not so Quine the " character cannot be made with a string literal so we need to make it by doing math on a similar character, in this case the unit separator character for reasons described later. The difference between this Quine and earlier attempts is that this we can get around the restriction of having to read the string forwards by making the string itself a palindrome. This way reading backwards is the same as reading it forwards.

So when the program starts it passes through a unit separator, then hits < which turns it around, it goes through the " and pushes the entire line. :3+ turns makes a " out of the final unit separator and @ terminates the program causing it to print.

Post Rock Garf Hunter

Posted 2011-01-28T00:34:05.293

Reputation: 55 382

3

Awk, 64 bytes

BEGIN{c="BEGIN{c=%c%s%c;printf c,34,c,34}";printf c,34,c,34}

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

3

Kotlin, 121 bytes

Nobody cared enough about Kotlin to post it so...

fun main(a:Array<String>){val s="fun main(a:Array<String>){val s=%c%s%1$1c;print(s.format(34,s))}";print(s.format(34,s))}

Try it online!

totallyhuman

Posted 2011-01-28T00:34:05.293

Reputation: 15 378

3

Groovy, 48 bytes

The language's pretty groovy too.

s="s=%c%s%c;printf(s,34,s,34)";printf(s,34,s,34)

Try it online!

totallyhuman

Posted 2011-01-28T00:34:05.293

Reputation: 15 378

3

Mathematica 17 19

ToString[#0][] & []

alephalpha

Posted 2011-01-28T00:34:05.293

Reputation: 23 988

Why Community Wiki? – MD XF – 2017-06-12T23:47:55.070

3

Zsh, 17 bytes

sed p<<a
sed p<<a

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

3

Octave, 28 bytes

Note: This doesn't work on TIO. I guess it's because TIO doesn't store the command history. It works on the desktop version. I tried it in Octave 4.2.1.


printf('%s',[history(1){:}])

So, what's going on here?

history is a function that can be used to read and manipulate the command history.

history(n) shows the n most recent commands you have typed, numbered:

>> x = 1 + 2;
>> y = x * 3;
>> history(3)
    7 x = 1 + 2;
    8 y = x * 3;
    9 history(3)

As you can see, x = 1 + 2 was the seventh command that was typed after the history was cleared the last time. The command history(3) is included in this list.

Now, history(1) is not a quine, since it gives:

>> history(1)
   10 history(1)

However, if you assign the output from history(1) to an output, you'll get:

>> x = history(1)
x =
{
  [1,1] = x = history(1)
}

It's still not a quine, but it's something we can work with.

Unwrapping this, and we're a bit closer:

>> [history(1){:}]
ans = [history(1){:}]

Notice that the entire command, including brackets are outputted.

Finally, if we print this as a string, using printf, we get:

>> printf('%s',[history(1){:}])
printf('%s',[history(1){:}])

Note: disp([history(1){:}]) almost works, but it appends a trailing newline.

Stewie Griffin

Posted 2011-01-28T00:34:05.293

Reputation: 43 471

Wouldn't disp([history(1){:}])\n work for 27 bytes? – caird coinheringaahing – 2017-08-29T14:47:18.000

3

><>, 8 bytes

#o<}-1:"

Try It Online

Copied the trick of copying and decrementing the # to get " from the other ><> answer, but uses both sides of the # to avoid needing to reverse the stack.

Edit: A much cleaner solution of the same length:

'rd3*>o<

Try it online!

Everyone forgets that a ' acts exactly the same as a ", but has usable divisors. Another 8 byte solution, but considered cheaty by some, 'r00g>o<

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

1

This is the same approach I used in the comments of the Original ><> answer: Funnily enough my comment and your post were 1 day off being exactly a year apart.

– Teal pelican – 2018-01-09T16:11:19.690

1

@Tealpelican. Wait, why didn’t we just use a single quote?

– Jo King – 2018-01-19T04:40:52.637

I always forget ><> can use ' or " but ' is so much more useful with having some usable divisors. – Teal pelican – 2018-01-19T09:39:22.957

3

Attache, 69 57 53 41 bytes

Printf[s:="Printf[s:=%s,Repr@s]",Repr@s]

Try it online! Surprised I didn't think of this sooner.


Print!Format[x:="Print!Format[x:=%s,Repr!x]",Repr!x]

In the end, the standard quine framework was most efficient :( . The 57-byter below is significantly more interesting.

Try it online!

BUT I found a cooler one, also for 53 bytes!

Print!Join[q:=["Print!Join[q:=", ",Repr!q]"],Repr!q]

Try it online!

57 bytes

Print!Format<~_,Repr!_~>["Print!Format<~_,Repr!_~>[%s]"]

This uses sneaky curried functions with blanks. When a function is called using f<~...~> syntax, it denotes a curried function. _1 represents the first curried argument, _2 the second, etc. _ is an alias for _1, so this saves us some bytes without duplicating our string.

Try it online!

69 bytes

Save["Save[%c%s%c]Print[Format[_,34,_,34]]"]Print[Format[_,34,_,34]]

Try it online! The trailing newline is significant.

Explanation

Save updates the abstract variable _ with the string

"Save[%c%s%c]Print[Format[_,34,_,34]]"

Then, this string is formatted with the arguments _, 34, _, and 34. This prints the string, the character 34 (a quote), and then those two again, which is the program.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

3

Noether, 30 bytes

"~a34BPaP34BPaP"~a34BPaP34BPaP

Try it online!

Basically, this works by pushing the string and storing it in the variable a, printing quotation marks (34B where B pushes the character with ASCII code 34) then printing a twice.

Beta Decay

Posted 2011-01-28T00:34:05.293

Reputation: 21 478

@OMᗺ That's only the Python/tio.run interpreter (which has a few bugs) . On the JS interpreter, there is no newline. – Beta Decay – 2018-08-11T13:59:01.753

Alright, that's the one on TIO so I tried with that sorry! Nvm, in that case. – ბიმო – 2018-08-11T14:01:26.723

3

Flobnar, 94 bytes

	9	f;	/*+{ ;{?06	0/9^[]={o)	*4_;=	9);];36   
:
g<
0+,|!<|@17
10:_\^>|p*
+5`<>
:*<  ^ <47!!!

Try it online!

There's some debate over whether the get instruction counts as reading the source code, but in this case, I'm not using it to read the executed code, but a data array on the first line (except for specifically reusing just the 9 character).

This reads and prints the data section, then reads and prints each character incremented by one to represent the code section.

Explanation:

.
..
.....<|@..   Start at the @ going left
..........   We use the | to evaluate the code beyond it and come back here
.....
.............

:
g<
0+,|!<....   Print the character on the first line at position n plus 0
.0........   Then go down from the |
.....
.............

.9
.
..
...|!.....
..:_......   If n > 5*9 then go left at the _ and return !n
.5`<.
.*<..........

.
..
...|!<....   Else go right and increment n
1.._\^....   And loop again
+...>
:............

.
..           Once we've ended the loop we come back to the original | going down
.....<|.17   And we put a 1 at the (1,4) position and repeat the main code again
.1....>|p*   This time adding 1 to each character
.....
.....^ <47...

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

3

Runic Enchantments, 7 6 bytes

"'<~@>

Try it online!

Huh, a multiple pointer quine actually works pretty well.

Explanation:

"'<~@>
  <  >   Start pointers going left and right
"'<      Left pointer pushes " to their stack
    @    And terminate the IP, printing the stack (")
     >   Right pointer wraps around
"        Start string literal
 '<~@>   Push as string
"        End string literal
 '<~     Push the < character, but pop it
    @    Terminate the IP, printing the stack ('<~@>)
         End the program as there are no IPs left

Edit: I realised you can replicate this with only one pointer

'<~@|"

Try it online!

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

Ha, didn't even see prior to posting this and you already beat me. Very clever use of the multiple IP feature.

– Draco18s no longer trusts SE – 2018-10-01T18:22:55.180

3

Symbolic Python, 30 bytes

_="_='_='+`_`+';__(_)'";__(_)

Try it online!

Yet another eval quine. The lack of being able to do %r in Symbolic Python is made up for Python 2's backticks, which are an alias for the repr function.

Explanation:

_="                   ";       # Assign the string to the _ variable
                        __(_)  # Eval the string
   _=                          # Assign to the _ variable
     '_='                      # The initial _=
         +`_`                  # The Python representation of the string
             +';__(_)'         # And the final evaling part
                               # Implicitly output the contents of _

An alternative that doesn't use the rather long eval function comes to 31 bytes, but I actually like it more.

_=';_="_="+`_`+_';_="_="+`_`+_

Try it online!

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

3

Julia 1.0, 32 bytes

".|>[show,print]".|>[show,print]

Try it online!

And here is a 35 byte quine that works in version 0.4 (And beats the previous answer):

x = "print(@show x)"
print(@show x)

Try it online!

H.PWiz

Posted 2011-01-28T00:34:05.293

Reputation: 10 962

1That, sir, is amazing! – primo – 2019-01-06T15:52:09.667

3

Gol><>, 8 7 6 bytes

"r2ssH

Hopefully this is not a previously used quine, I was messing around for another challenge having to do with quines, and I ended up creating this!

2nd program (the most recent), 7 bytes

":P}rH!

Courtesy of JoKing, who knocked an entire byte off the original!

1st program (the original), 8 bytes

":P&r&H!

I know this isn't the smallest, but it is my first quine in Gol><> (I did it entirely on my own!). Link to the interpreter in the title!

Try it online!

Code Breakdown

":P&r&H!

First, the " command collects all of the chars and rewraps around the program

Then the : command doubles the last symbol in the program, the !

Then this is incremented, and saved by the register

The stack is then reversed and the value is put back

Then the entire stack is outputted as characters and then the program halts

KrystosTheOverlord

Posted 2011-01-28T00:34:05.293

Reputation: 681

you can use } to rotate the stack instead of &, Try it online!

– Jo King – 2019-02-05T23:41:28.270

@JoKing wow, that cuts one byte off, thanks, is it okay if I put that as the answer (with credit to you of course) – KrystosTheOverlord – 2019-02-05T23:53:58.197

of course you can. PPCG is a lot about cooperative answers rather than competition and it's nice to help new users figure out shortcuts in their chosen language(s) – Jo King – 2019-02-05T23:58:10.757

@JoKing Thanks, credits are also to you! Are you a Gol><> coder, if you have any experience, do you have tips, I really like it! – KrystosTheOverlord – 2019-02-06T00:16:51.450

there's not really much Gol><> specific advice, but I would recommend getting familiar with its parent language, ><>, first. – Jo King – 2019-02-06T04:36:20.233

@JoKing Alright, thank you for the advice! – KrystosTheOverlord – 2019-02-06T12:12:43.197

Let us continue this discussion in chat.

– KrystosTheOverlord – 2019-02-06T17:46:18.777

3

Rust, 72 66 bytes

fn main(){print!("{}{0:?})}}","fn main(){print!(\"{}{0:?})}}\",")}

Try it online!

NieDzejkob

Posted 2011-01-28T00:34:05.293

Reputation: 4 630

3

Fueue, 411 391 381 376 bytes

(5(2(7(1(8(0(0(4(0(2(5(2(4(9(9(0(4(9(0(2(4(2(8(2(1(6(9(0(6(2(9(5(9(5(9(0(1(1(4(0(3(2(3(1(3(1(9(1(8(1(1(1(0(1(4(0(1(2(3(1(3(1(7(1(6(1(9(0(4(9(9(5(8(2(4(9(9(0(4(9(4(9(1(6(9(0(4(9(1(0(1(6(4(9(9(5(4(9(9(0(4(9(4(9(1(6(9(0(4(9(6(2(9(5(9(0(3(1(3(1(4(9(1(1(0(2(6(1(3(1(3(1(0(2(4(2(9(0(4(9(6(2(1(6(4(9(1(6[10(:91(H49~)~48<]):[[)+$7--32+*$5--10)~[<~)~~])~!]~[~)~~])~:[)--~+40--48)~:]~]

Try it online!

See also Ørjan Johansen's answer.

Basic idea (outdated):

(7(1(9(5(1(1(8(0...                  Data.
[9!(91[+(H~)]57<33]                  Begin the second pass and end the program on second pass.
):[                                  Duplicate and evaluate the block.
    [)+$7--32+*$5--10)~[<~)~~])~!]   On the second pass, print b*10+a+32 for each two digits a, b.
    )()[~)~~]~:~<                    Copy a digit and evaluate the next line between copies.
    [)----40+--~)48~:~~]             Print "("+digit and duplicate and evaluate the whole block on the next digit.
]

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

3

Golunar, 951 bytes (394.25 bytes as an integer value)

19370043316195921194914466480856680152267470323963447024756684537596068724128114478400203537500358028693578705195025299449504112473728653294217406768139954805008550643064305270958743186186490023003785512463398359429631224818444304976679217098389450981926661910005004089131207223929032173888419619738722341444212432611576207643452266161684471788295034889655803444137372629364500165719019777515305922257911642994836581634099155833200157295629218533465854143898419293035289733581625252699105530843807023973345521520887128012736565874423200184723012755626596238647926406709693583878890472621210970350861368171259284533764490596207310864352873729240842719608391238098412446205860013948766486129442046252306334230243913196704614648889659870117069927719874852423159076941049170045933025772364248625729725500550726133134993128102614696728457139079375133324957922066270555810085574853273966267981675757808791933974619299446035844180580831907739236954600685575

Golunar is the decimal representation of the number of zeros that a Unary code would need. It translates to this brainfuck code:

->+>+>+>>>>>>>>>>>>+>+>>>+>+>+>+>+>>>>>>+>>>+>>>+>>>+>>>+>>>+>>+>>>>+>+>>+>>>+>>>+>>>+>>>+>>>+>>>+>>>+>+>>>>>>>+>+>+>+>>>+>>>>+>+>+>>>+>+>+>>+>>+>>>+>+>+>+>+>+>>>>>+>+>+>>>+>+>+>>>>>>>>+>+>>>>>+>>+>>>+>>>+>+>>+>+>+>>+>>+>>>+>+>>>+>+>>+>+>+>+>>+>>>+>+>+>>>>>+>+>+>>>+>+>+>>>>>>>>+>+>>>>>>>+>+>+>+>>>+>>>>+>>+>+>+>+>+>>>>>>+>>+>>>>+>+>>>>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>>>>>+>>>+>>+>+>+>+>+>>>+>+>+>>>+>>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>>>+>+>>>+>+>+>>>+>+>>+>+>+>>+>>+>>>+>+>>>+>+>>+>+>>+>>>+>>>>>>+>>>+>>>>>>+>>>+>>+>+>+>>>>>+>+>+>+>>>>>>+>>>>>>+>>+>+>+>>+>>+>>>+>>>+>+>+>+>>>>+>+>+>+>>+>>>+>>>+>+>+>>>>>+>+>>>>>>>+>+>+>+>+>>+>>>+>+>+>+>>>>+>+>>+>>>>>>+>>>+>>>>>>+>>+>+>+>>>>>+>+>>+>>>>>>>>>+>+>>+>+>>+>+[[>>+[>]+>++>+[<]<-]>>[>]<<-[<]<<+]+>+>-[>]++>++>++[[-<+]-<[-<[>++<-[>++<-[>++<-[>++<-[>--------<<[-]++>-[>++<-]]]]]]>[<+>-]+<<]>>[>>]<[>]<-[[-<+]-<<+>[>>]<[>]]<+]<[<<]>>[+++++++[<++++++>-]<.>>>]

Try it online!

I couldn't find an online Golunar interpreter, but you can use this Golunar to brainfuck converter to get the brainfuck code and then execute it.

This code is inspired by a brainfuck quine of Eric Bosman and Daniel B Cristofani. First it reads a list of bits that represent the bit-codes of the code part, then it builds up a list of bits that represent the ">" and "+" characters needed to print the first list. Those lists are merged and hold the binary value of the Golunar code. In the last step, the decimal value of the binary number are computed and printed.

[ 
tape: [decimal digits], value start marker/VS(-1)(starting cell), [input bits], between binary marker/BB(0), [binary output data]

input bits are 0 or 1, output bits are in reversed order and have the values 1(used) or 2(used and set)
input must be given in reversed order

decimal digits consist of two cells per value (value, digit used marker(DU)(1))

bit values:
> 000
< 001
+ 010
- 011
. 100
, 101
[ 110
] 111

]

-                       set VS

                    set input bits
>+>+>+>>>>>>>>>>>>+>+>>>+>+>+>+>+>>>>>>+>>>+>>>+>>>+>>>+>>>+>>+>>>>+>+>>+>>>+>>>+>>>+>>>+>>>+>>>+>>>
+>+>>>>>>>+>+>+>+>>>+>>>>+>+>+>>>+>+>+>>+>>+>>>+>+>+>+>+>+>>>>>+>+>+>>>+>+>+>>>>>>>>+>+>>>>>+>>+>>>+
>>>+>+>>+>+>+>>+>>+>>>+>+>>>+>+>>+>+>+>+>>+>>>+>+>+>>>>>+>+>+>>>+>+>+>>>>>>>>+>+>>>>>>>+>+>+>+>>>+>>
>>+>>+>+>+>+>+>>>>>>+>>+>>>>+>+>>>>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>
>>>>>+>>>+>>+>+>+>+>+>>>+>+>+>>>+>>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>+>+>>>>>>+>+>+>+>>+>>>>+>>>+>
>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>+>>+>>>>+>>>+>>>>>>+>+>+>>>+>+>>>+>+>+>
>>+>+>>+>+>+>>+>>+>>>+>+>>>+>+>>+>+>>+>>>+>>>>>>+>>>+>>>>>>+>>>+>>+>+>+>>>>>+>+>+>+>>>>>>+>>>>>>+>>+
>+>+>>+>>+>>>+>>>+>+>+>+>>>>+>+>+>+>>+>>>+>>>+>+>+>>>>>+>+>>>>>>>+>+>+>+>+>>+>>>+>+>+>+>>>>+>+>>+>>>
>>>+>>>+>>>>>>+>>+>+>+>>>>>+>+>>+>>>>>>>>>+>+>>+>+>>+>

                    list rebuilding loop: append bits for "greater than" and plus symbols to the right of input data
+[                      for each input bit
  [                     while bit is greater than 0
    >>+                 copy bit to out data
    [>]+>++>+           append bits for plus (used markers plus 010)
    [<]<-               decrement in value
  ]
  >>[>]<<-              change most right character from plus to gt (010 to 000)
  [<]                   return to BB
  <<+                   repeat if not on VS
]
+>+>-                   prepare binary to decimal routine: set VS DU and first 1

[>]++>++>+              append bits for minus (011)

                    binary to decimal loop: use "double and add algorithm" to calculate the digits of the decimal value
+[                      if not on VS then
  [-<+]-                restore current bit value and go to VS
  <                     go to first DU
  [                 digit doubling loop
    -<                  remove DU and go to corresponding digit
    [
      >++<-             decrement current value and add 2 to temp value four times
      [
        >++<-
        [
          >++<-
          [
            >++<-
            [                   if value was greater than 4 then
              >---- ----        subtract 8 from temp
              <<[-]++           set next digit temp = 2 (DU plus 1)
              >-                decrement current digit
              [>++<-]           set temp = remaining value * 2
            ]
          ]
        ]
      ]
    ]
    >[<+>-]             set current digit = temp
    +                   set DU
    <<                  go to next digit
  ]                 end of digit doubling loop
  >>[>>]<[>]<           go to current bit
  -[                    if bit is 2 (used plus 1)
    [-<+]-              delete bit and go to VS
    <<+                 increment least significant digit
    >[>>]<[>]           go to current bit
  ]
  <+                    if not on VS then repeat  
]                   end of binary to decimal loop

<[<<]>                  go to most significant digit
>[                  printing loop: for each DU print corresponding value
  +++++++[<++++++>-]<.  add 48 to value (ASCII 0) and print
  >>>                   go to next DU
]

Dorian

Posted 2011-01-28T00:34:05.293

Reputation: 1 521

3

Perl 5, 35 bytes

$_=q(print qq(\$_=q($_);eval));eval

Try it online!

booshlinux

Posted 2011-01-28T00:34:05.293

Reputation: 81

Welcome! Please consider adding an explanation or a link to an online interpreter. Code-only answers tend to be automatically flagged as low-quality. – mbomb007 – 2019-09-20T15:42:30.697

1No problem. I didn't realize that tio.run has an area to copy/paste submission markdown for code golf. Very cool. – booshlinux – 2019-09-20T15:45:41.887

3

Bash, 65 bytes

set -o history
echo "set -o history"
history|tail -n 2|cut -c 8-

Bash disables the command-history function in scripts, but you can turn it on manually with 'set-o history'.

This first command is obviously not stored in the shell's history file, so the second command prints the same text to the terminal.

The third command pulls the last two out of the history file and cleans them up for displaying.

The output matches:

set -o history
echo "set -o history"
history|tail -n 2|cut -c 8-

Kevin

Posted 2011-01-28T00:34:05.293

Reputation: 3 123

reads its source no matter what – Erik the Outgolfer – 2016-06-15T08:39:40.893

3

(ucb)logo - 28 chars

to q
po "q
pr "q
bye
end

q

Geoff Reedy

Posted 2011-01-28T00:34:05.293

Reputation: 2 828

3

Pyth, 11 bytes

jN*2]"jN*2]

Surprised this hadn't been posted yet :P

TheInitializer

Posted 2011-01-28T00:34:05.293

Reputation: 829

3

ShapeScript, 16 bytes

'"%r"@%"0?!"'0?!

This answer is non-competing, since ShapeScript is a few years younger than this challenge.

Try it online!

Verification

$ shapescript quine.shape | diff -sq - quine.shape
Files - and quine.shape are identical

How it works

'       Push a string that, when evaluated, does the following.
  "%r"  Push this formatting string. %r gets replaced by a string
        representation of the corresponding argument.
  @     Swap the string that is being evaluated on top of the stack.
  %     Apply formatting to the string on top of the stack.
  "0?!" Push that string.
'
0?!     Push a copy of the previous string and evaluate it.

ShapeScript, 32 bytes

'"'"'"'1?3?+3*2?+@+@+@#"0?!"'0?!

This version does not use string formatting. It's not particularly short, but I find it rather interesting.

Try it online!

How it works

'"'     Push a double quote singleton string.
"'"     Push a single quote singleton string.
'       Push a string that, when evaluated, does the following:
  1?3?    Copy the second and fourth topmost stack items.
          This pushes a copy of the single, then the double quote.
  +3*     Concatenate both and repeat the result three times.
  2?+     Copy the third topmost stack item and append it to the string.
          We now have a string of the first seven characters of the source.
  @+      Swap with the string on the stack (the string that is being
          evaluated) and concatenate.
  @+      Swap with the original single quote and concatenate.
  @#      Swap with the original double quote and discard it.
  "0?!"   Push that string.
'
0?!     Push a copy of the above string and evaluate it.

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

3

SWI-Prolog, 22 bytes

a :-
        listing(a).
 

A surprisingly short and elegant solution.

The 8 spaces and the new line (the space in the last line is just to display the empty line, there is actually no space) are both required in SWI-Prolog because that is the formatting that listing displays in the interpreter.

Fatalize

Posted 2011-01-28T00:34:05.293

Reputation: 32 976

3

Brachylog, 3 bytes

@Qw

This expects no input or output, i.e. brachylog_main(_,_)..

@Q is the string "@Qw", and w is the write predicate.

A 34 bytes quine without a specific built-in for quines

"~c~s~cS:[34:S:34]rw"S:[34:S:34]rw

This is a basic quine strategy applied to this language:

"~c~s~cS:[34:S:34]rw"              § Create a string containing the source code
                                   § ~c~s~c gets replaced by the arguments of predicate w
                                   § in their respective order in the list
                                   § ~c prints the arg as a char code, ~s as a string
                     S             § Call this string S
                      :[34:S:34]rw § Write the format S to the output with args " (34),
                                   § S and " replacing ~c, ~s and ~c respectively

Fatalize

Posted 2011-01-28T00:34:05.293

Reputation: 32 976

3

C#, 188 157 149 bytes

class A{static void Main(){var a="class A{{static void Main(){{var a={0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Con‌​sole.Write(a,'"',a);‌​}}

Basic quine, just contains a self-containing string.

LegionMammal978

Posted 2011-01-28T00:34:05.293

Reputation: 15 731

More shorter version (149 bytes): class A{static void Main(){var a="class A{{static void Main(){{var a={0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} – Ivan Kochurkin – 2016-09-15T11:19:44.787

3

Squeak Smalltalk - 91!

I just translated my Factor answer:

[:b|b value:b]value:[:b|Transcript show: '[:b|b value:b]value:[:b|' , b sourceString , ']']

Just DoIt! in a Workspace, prints itself to the Transcript.

Blocks don't have a reference to self, so i used another block as a combinator.

I'm sure there MUST be a shorter Smalltalk quine! After all it's Small-talk :P

No cheating -- that means that you can't just read the source file and print it.

At first I thought BlockClosure>>sourceString could be cheating as stated in the question, but looking at the Squeak implementation, doesn't seem to be reading the sources file1, but decompiling the block.

1: Smalltalk's image usually saves compiled code, and links to an external file with the original source.

fede s.

Posted 2011-01-28T00:34:05.293

Reputation: 945

It's cheating if b is your whole program. However, if b is a function or string literal, it's fine. – wizzwizz4 – 2016-02-14T09:05:17.410

@wizzwizz4 Thanks for the clarification! – fede s. – 2016-02-14T21:56:55.037

Yeah sourceString looks like "read[ing] the source file and print[ing] it". – Martin Ender – 2016-02-14T22:34:36.023

@MartinBüttner I just checked the implementation, and it decompiles the BlockClosure, it doesn't use the sources file. The message-chain is: sourceString -> self printSourceOn: -> self decompile. Not sure if it's cheating in a general sense, but I think as stated in the question it's legit, right? – fede s. – 2016-02-15T01:17:57.163

1The second largest program I've seen. 91! = 1.352002e+140 :P – user48538 – 2016-05-16T20:29:37.767

@zyabin101 That's weird, I get '91! Argument expected ->' if I printIt. What version of squeak are you using? :P – fede s. – 2016-05-16T20:37:31.500

I'm using Google for that. :P – user48538 – 2016-05-17T09:55:20.420

@fedes. Try: USE: math.factorials 91 n!, you get 135200152767840296255166568759495142147586866476906677791741734597153670771559994765685283954750449427751168336768008192000000000000000000000 :D – cat – 2016-05-17T22:48:42.307

@cat is that a Monticello package? I can't find it on SmalltakHub... you guys make no sense! – fede s. – 2016-05-17T22:56:17.857

1

@fedes. probably needs more jQuery

– cat – 2016-05-17T23:23:41.233

3

Go, 115 bytes

package main;import."fmt";func main(){s:="package main;import.\"fmt\";func main(){s:=%q;Printf(s,s);}";Printf(s,s)}

Blowing the previous Go record out of the water!

EMBLEM

Posted 2011-01-28T00:34:05.293

Reputation: 2 179

Nice job, there! – Conor O'Brien – 2016-03-23T17:53:04.810

3

Python, 104 bytes

Uses eval and repr

a = "print 'a','=', repr(eval('a'))\nprint eval('a'),\n"
print 'a','=', repr(eval('a'))
print eval('a'),

Alexandru

Posted 2011-01-28T00:34:05.293

Reputation: 5 485

1repr(x)==\x`` – CalculatorFeline – 2016-03-10T23:58:28.293

3Since this is code-golf, you might want to include a byte count. – nyuszika7h – 2014-04-28T12:33:08.493

3

Ouroboros, 30 bytes

;T...!59*\1=33*++o.9=\1=2*+(1"

The T should be replaced with a literal tab character.

About Ouroboros

Each line of an Ouroboros program represents a snake eating its own tail, with the beginning of the line being the head and the end being the tail. The only control flow operations are commands to eat or regurgitate characters of the tail. When the instruction pointer reaches the last part of the line that hasn't been eaten, it loops back to the beginning. If the instruction pointer is swallowed, execution halts.

While Ouroboros has some similarities to 2D languages such as ><>, its limited control flow options presented a challenge for quine construction. The only way to skip an instruction is to put it near the end and swallow it--which means instructions near the beginning basically can't be skipped. It took some experimenting before I found a quine structure that worked.

Explanation

The core idea is similar to a ><> or Befunge quine: with a wrapping IP, a single " mark can be used to stringify the code on one pass and execute it on another. Ouroboros automatically pushes strings to the stack in reverse order, which simplifies things. However, we have to put the quotation mark at the end so we can swallow it to avoid pushing the string multiple times. That means that the code must be executed first, then the string pushed, and then the code executed again until the output is complete.

On every pass, the code does two main things: output a character and swallow 0 or more characters of code.

...!59*\1=33*++o

On the first pass, the stack is empty and treated as zero. Logically negating and multiplying by 59 gives the character code for ;, the first character of the quine. On the final pass, the 1 that was pushed right before the string (at the very end of the code) is encountered, to which we add 33 to turn it into 34, the closing ". On other passes, the character code is output unchanged. In pseudocode: output (!top)*59 + (top==1)*33 + top

.9=\1=2*+(

There are two passes on which code needs to be swallowed. On the first pass after we push the string (when we print the tab) the quotation mark has to go; and on the last pass (after we've processed the whole string and the 1 is left on the stack) two more characters are eaten to swallow the instruction pointer and end the program. On every other pass, don't eat anything. In pseudocode: swallow (top==9)+(top==1)*2

One problem remains: since we output the first character of code on the initial pass, we have to drop it (;) immediately after pushing the string so it won't be output a second time. But we don't want to drop anything on subsequent passes. Fortunately, at the end of each iteration we push another 1 to the stack, which is immediately dropped at the beginning of the next pass.

Try it out

// Define Stack class
function Stack() {
  this.stack = [];
  this.length = 0;
}
Stack.prototype.push = function(item) {
  this.stack.push(item);
  this.length++;
}
Stack.prototype.pop = function() {
  var result = 0;
  if (this.length > 0) {
    result = this.stack.pop();
    this.length--;
  }
  return result;
}
Stack.prototype.top = function() {
  var result = 0;
  if (this.length > 0) {
    result = this.stack[this.length - 1];
  }
  return result;
}
Stack.prototype.toString = function() {
  return "" + this.stack;
}

// Define Snake class
function Snake(code) {
  this.code = code;
  this.length = this.code.length;
  this.ip = 0;
  this.ownStack = new Stack();
  this.currStack = this.ownStack;
  this.alive = true;
  this.wait = 0;
  this.partialString = this.partialNumber = null;
}
Snake.prototype.step = function() {
  if (!this.alive) {
    return null;
  }
  if (this.wait > 0) {
    this.wait--;
    return null;
  }
  var instruction = this.code.charAt(this.ip);
  var output = null;
  console.log("Executing instruction " + instruction);
  if (this.partialString !== null) {
    // We're in the middle of a double-quoted string
    if (instruction == '"') {
      // Close the string and push its character codes in reverse order
      for (var i = this.partialString.length - 1; i >= 0; i--) {
        this.currStack.push(this.partialString.charCodeAt(i));
      }
      this.partialString = null;
    } else {
      this.partialString += instruction;
    }
  } else if (instruction == '"') {
    this.partialString = "";
  } else if ("0" <= instruction && instruction <= "9") {
    if (this.partialNumber !== null) {
      this.partialNumber = this.partialNumber + instruction;  // NB: concatenation!
    } else {
      this.partialNumber = instruction;
    }
    next = this.code.charAt((this.ip + 1) % this.length);
    if (next < "0" || "9" < next) {
      // Next instruction is non-numeric, so end number and push it
      this.currStack.push(+this.partialNumber);
      this.partialNumber = null;
    }
  } else if ("a" <= instruction && instruction <= "f") {
    // a-f push numbers 10 through 15
    var value = instruction.charCodeAt(0) - 87;
    this.currStack.push(value);
  } else if (instruction == "$") {
    // Toggle the current stack
    if (this.currStack === this.ownStack) {
      this.currStack = this.program.sharedStack;
    } else {
      this.currStack = this.ownStack;
    }
  } else if (instruction == "s") {
    this.currStack = this.ownStack;
  } else if (instruction == "S") {
    this.currStack = this.program.sharedStack;
  } else if (instruction == "l") {
    this.currStack.push(this.ownStack.length);
  } else if (instruction == "L") {
    this.currStack.push(this.program.sharedStack.length);
  } else if (instruction == ".") {
    var item = this.currStack.pop();
    this.currStack.push(item);
    this.currStack.push(item);
  } else if (instruction == "m") {
    var item = this.ownStack.pop();
    this.program.sharedStack.push(item);
  } else if (instruction == "M") {
    var item = this.program.sharedStack.pop();
    this.ownStack.push(item);
  } else if (instruction == "y") {
    var item = this.ownStack.top();
    this.program.sharedStack.push(item);
  } else if (instruction == "Y") {
    var item = this.program.sharedStack.top();
    this.ownStack.push(item);
  } else if (instruction == "\\") {
    var top = this.currStack.pop();
    var next = this.currStack.pop()
    this.currStack.push(top);
    this.currStack.push(next);
  } else if (instruction == "@") {
    var c = this.currStack.pop();
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(c);
    this.currStack.push(a);
    this.currStack.push(b);
  } else if (instruction == ";") {
    this.currStack.pop();
  } else if (instruction == "+") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a + b);
  } else if (instruction == "-") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a - b);
  } else if (instruction == "*") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a * b);
  } else if (instruction == "/") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a / b);
  } else if (instruction == "%") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a % b);
  } else if (instruction == "_") {
    this.currStack.push(-this.currStack.pop());
  } else if (instruction == "I") {
    var value = this.currStack.pop();
    if (value < 0) {
      this.currStack.push(Math.ceil(value));
    } else {
      this.currStack.push(Math.floor(value));
    }
  } else if (instruction == ">") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a > b));
  } else if (instruction == "<") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a < b));
  } else if (instruction == "=") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a == b));
  } else if (instruction == "!") {
    this.currStack.push(+ !this.currStack.pop());
  } else if (instruction == "?") {
    this.currStack.push(Math.random());
  } else if (instruction == "n") {
    output = "" + this.currStack.pop();
  } else if (instruction == "o") {
    output = String.fromCharCode(this.currStack.pop());
  } else if (instruction == "r") {
    var input = this.program.io.getNumber();
    this.currStack.push(input);
  } else if (instruction == "i") {
    var input = this.program.io.getChar();
    this.currStack.push(input);
  } else if (instruction == "(") {
    this.length -= Math.floor(this.currStack.pop());
    this.length = Math.max(this.length, 0);
  } else if (instruction == ")") {
    this.length += Math.floor(this.currStack.pop());
    this.length = Math.min(this.length, this.code.length);
  } else if (instruction == "w") {
    this.wait = this.currStack.pop();
  }
  // Any unrecognized character is a no-op
  if (this.ip >= this.length) {
    // We've swallowed the IP, so this snake dies
    this.alive = false;
    this.program.snakesLiving--;
  } else {
    // Increment IP and loop if appropriate
    this.ip = (this.ip + 1) % this.length;
  }
  return output;
}
Snake.prototype.getHighlightedCode = function() {
  var result = "";
  for (var i = 0; i < this.code.length; i++) {
    if (i == this.length) {
      result += '<span class="swallowedCode">';
    }
    if (i == this.ip) {
      if (this.wait > 0) {
        result += '<span class="nextActiveToken">';
      } else {
        result += '<span class="activeToken">';
      }
      result += escapeEntities(this.code.charAt(i)) + '</span>';
    } else {
      result += escapeEntities(this.code.charAt(i));
    }
  }
  if (this.length < this.code.length) {
    result += '</span>';
  }
  return result;
}

// Define Program class
function Program(source, speed, io) {
  this.sharedStack = new Stack();
  this.snakes = source.split(/\r?\n/).map(function(snakeCode) {
    var snake = new Snake(snakeCode);
    snake.program = this;
    snake.sharedStack = this.sharedStack;
    return snake;
  }.bind(this));
  this.snakesLiving = this.snakes.length;
  this.io = io;
  this.speed = speed || 10;
  this.halting = false;
}
Program.prototype.run = function() {
  this.step();
  if (this.snakesLiving) {
    this.timeout = window.setTimeout(this.run.bind(this), 1000 / this.speed);
  }
}
Program.prototype.step = function() {
   for (var s = 0; s < this.snakes.length; s++) {
    var output = this.snakes[s].step();
    if (output) {
      this.io.print(output);
    }
  }
  this.io.displaySource(this.snakes.map(function (snake) {
      return snake.getHighlightedCode();
    }).join("<br>"));
 }
Program.prototype.halt = function() {
  window.clearTimeout(this.timeout);
}

var ioFunctions = {
  print: function (item) {
    var stdout = document.getElementById('stdout');
    stdout.value += "" + item;
  },
  getChar: function () {
    if (inputData) {
      var inputChar = inputData[0];
      inputData = inputData.slice(1);
      result = inputChar.charCodeAt(0);
    } else {
      result = -1;
    }
    var stdinDisplay = document.getElementById('stdin-display');
    stdinDisplay.innerHTML = escapeEntities(inputData);
    return result;
  },
  getNumber: function () {
    while (inputData && (inputData[0] < "0" || "9" < inputData[0])) {
      inputData = inputData.slice(1);
    }
    if (inputData) {
      var inputNumber = inputData.match(/\d+/)[0];
      inputData = inputData.slice(inputNumber.length);
      result = +inputNumber;
    } else {
      result = -1;
    }
    var stdinDisplay = document.getElementById('stdin-display');
    stdinDisplay.innerHTML = escapeEntities(inputData);
    return result;
  },
  displaySource: function (formattedCode) {
    var sourceDisplay = document.getElementById('source-display');
    sourceDisplay.innerHTML = formattedCode;
  }
};
var program = null;
var inputData = null;
function showEditor() {
  var source = document.getElementById('source'),
    sourceDisplayWrapper = document.getElementById('source-display-wrapper'),
    stdin = document.getElementById('stdin'),
    stdinDisplayWrapper = document.getElementById('stdin-display-wrapper');
  
  source.style.display = "block";
  stdin.style.display = "block";
  sourceDisplayWrapper.style.display = "none";
  stdinDisplayWrapper.style.display = "none";
  
  source.focus();
}
function hideEditor() {
  var source = document.getElementById('source'),
    sourceDisplay = document.getElementById('source-display'),
    sourceDisplayWrapper = document.getElementById('source-display-wrapper'),
    stdin = document.getElementById('stdin'),
    stdinDisplay = document.getElementById('stdin-display'),
    stdinDisplayWrapper = document.getElementById('stdin-display-wrapper');
  
  source.style.display = "none";
  stdin.style.display = "none";
  sourceDisplayWrapper.style.display = "block";
  stdinDisplayWrapper.style.display = "block";
  
  var sourceHeight = getComputedStyle(source).height,
    stdinHeight = getComputedStyle(stdin).height;
  sourceDisplayWrapper.style.minHeight = sourceHeight;
  sourceDisplayWrapper.style.maxHeight = sourceHeight;
  stdinDisplayWrapper.style.minHeight = stdinHeight;
  stdinDisplayWrapper.style.maxHeight = stdinHeight;
  sourceDisplay.textContent = source.value;
  stdinDisplay.textContent = stdin.value;
}
function escapeEntities(input) {
  return input.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function resetProgram() {
  var stdout = document.getElementById('stdout');
  stdout.value = null;
  if (program !== null) {
    program.halt();
  }
  program = null;
  inputData = null;
  showEditor();
}
function initProgram() {
  var source = document.getElementById('source'),
    stepsPerSecond = document.getElementById('steps-per-second'),
    stdin = document.getElementById('stdin');
  program = new Program(source.value, +stepsPerSecond.innerHTML, ioFunctions);
  hideEditor();
  inputData = stdin.value;
}
function runBtnClick() {
  if (program === null || program.snakesLiving == 0) {
    resetProgram();
    initProgram();
  } else {
    program.halt();
    var stepsPerSecond = document.getElementById('steps-per-second');
    program.speed = +stepsPerSecond.innerHTML;
  }
  program.run();
}
function stepBtnClick() {
  if (program === null) {
    initProgram();
  } else {
    program.halt();
  }
  program.step();
}
function sourceDisplayClick() {
  resetProgram();
}
.container {
    width: 100%;
}
.so-box {
    font-family:'Helvetica Neue', Arial, sans-serif;
    font-weight: bold;
    color: #fff;
    text-align: center;
    padding: .3em .7em;
    font-size: 1em;
    line-height: 1.1;
    border: 1px solid #c47b07;
    -webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    background: #f88912;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
}
.control {
    display: inline-block;
    border-radius: 6px;
    float: left;
    margin-right: 25px;
    cursor: pointer;
}
.option {
    padding: 10px 20px;
    margin-right: 25px;
    float: left;
}
h1 {
    text-align: center;
    font-family: Georgia, 'Times New Roman', serif;
}
a {
    text-decoration: none;
}
input, textarea {
    box-sizing: border-box;
}
textarea {
    display: block;
    white-space: pre;
    overflow: auto;
    height: 50px;
    width: 100%;
    max-width: 100%;
    min-height: 25px;
}
span[contenteditable] {
    padding: 2px 6px;
    background: #cc7801;
    color: #fff;
}
#stdout-container, #stdin-container {
    height: auto;
    padding: 6px 0;
}
#reset {
    float: right;
}
#source-display-wrapper , #stdin-display-wrapper{
    display: none;
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid black;
    box-sizing: border-box;
}
#source-display , #stdin-display{
    font-family: monospace;
    white-space: pre;
    padding: 2px;
}
.activeToken {
    background: #f93;
}
.nextActiveToken {
    background: #bbb;
}
.swallowedCode{
    color: #999;
}
.clearfix:after {
    content:".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}
.clearfix {
    display: inline-block;
}
* html .clearfix {
    height: 1%;
}
.clearfix {
    display: block;
}
<!--
Designed and written 2015 by D. Loscutoff
Much of the HTML and CSS was taken from this Befunge interpreter by Ingo Bürk: http://codegolf.stackexchange.com/a/40331/16766
-->
<div class="container">
<textarea id="source" placeholder="Enter your program here" wrap="off">; ...!59*\1=33*++o.9=\1=2*+(1"</textarea>
<div id="source-display-wrapper" onclick="sourceDisplayClick()"><div id="source-display"></div></div></div><div id="stdin-container" class="container">
<textarea id="stdin" placeholder="Input" wrap="off"></textarea>
<div id="stdin-display-wrapper" onclick="stdinDisplayClick()"><div id="stdin-display"></div></div></div><div id="controls-container" class="container clearfix"><input type="button" id="run" class="control so-box" value="Run" onclick="runBtnClick()" /><input type="button" id="pause" class="control so-box" value="Pause" onclick="program.halt()" /><input type="button" id="step" class="control so-box" value="Step" onclick="stepBtnClick()" /><input type="button" id="reset" class="control so-box" value="Reset" onclick="resetProgram()" /></div><div id="stdout-container" class="container"><textarea id="stdout" placeholder="Output" wrap="off" readonly></textarea></div><div id="options-container" class="container"><div class="option so-box">Steps per Second:
<span id="steps-per-second" contenteditable>20</span></div></div>

DLosc

Posted 2011-01-28T00:34:05.293

Reputation: 21 213

3

R, 73 bytes (incl. tabs and newlines)

(f=function()
{
    cat("(f=function()\n")
    print(body(f))
    cat(")()")
}
)()

Shorter, less interesting quines are possible: function()1 is 11 bytes. + (1 byte) is an arguable quine, since the command prompt for an unfinished line is a plus sign by default, and + on its own counts as an unfinished line.

JDL

Posted 2011-01-28T00:34:05.293

Reputation: 1 135

It is necessary to format exactly this way (can't remove tabs or replace newline with ";"), otherwise the output will not exactly match the input. – JDL – 2016-08-25T14:17:25.820

A more trivial example is function()1 (11 bytes) but that's kinda boring... – JDL – 2016-08-26T14:06:21.160

2

Your 14 bytes solution is not easy to find. And I don't find it boring at all! Suggestion: keep the 73 solution but list this solution as 14 bytes one so it found more easily using the leaderboard.

– JayCe – 2018-05-16T17:56:30.910

I may be misreading some details of how programs are defined in R, but I think list() is a shorter trivial solution? I can't do command-line verification, but it certainly plays interactively and on TIO (though you might argue a newline is needed for the latter) Try it online!

– CriminallyVulgar – 2019-01-31T15:37:03.657

yes, list() (and numeric(0) and friends) are all quines in R. – JDL – 2019-02-01T08:57:29.533

3

J 4 bytes

I know this competition is probably dead but I wanted to put my answer in.

Just found this by accident

1 b.

J 1 bytes

0

XiKuuKy

Posted 2011-01-28T00:34:05.293

Reputation: 369

1Nice... I think you found the shortest possible quine once again! – Erik the Outgolfer – 2016-09-14T13:32:14.040

3These basically rely on the repl state of J, and are rather trivial. But, if it's happening like this, 1& is shorter than 1 b.. – Conor O'Brien – 2016-10-14T22:58:01.240

28 Bytes for a full program: (echo@,quote)'(echo@,quote)' – Bolce Bussiere – 2018-04-02T02:29:07.107

3

Turtlèd, 68 63 53 54 bytes (newlines)

rewrote

@##'@r,r,r-{ +.r_}r{ +.r_}'#'@r,r,r-{ +.r_}r{ +.r_}'f

Try it online!

Explanation

@#         Set character variable to #. Useful because this cannot occur in string var     
  #                        #  Set the string var to...
   '@r,r,r-{ +.r_}r{ +.r_}'   This string (quotes included. coincidental)
                            '@r,r,r            Write out first three chars of program: @##
                                   -{ +.r_}r   Write out the string var, then #, move right
                                            { +.r_} Write out the string var again, write #
                                                   'f   overwrite last # with f

Destructible Lemon

Posted 2011-01-28T00:34:05.293

Reputation: 5 908

3

MATL, 12 bytes

'&DtU'
&DtU

(the code has a trailing newline).

Try it online!

Explanation

'&DtU'    % Push this string
&D        % String representation (adds quote marks)
t         % Duplicate
U         % Evaluate (removes quote marks)
          % Implicitly display each string followed by a newline

Luis Mendo

Posted 2011-01-28T00:34:05.293

Reputation: 87 464

I take it that it would not be shorter to do &D after t, avoiding U? – ETHproductions – 2016-10-23T02:56:59.510

@ETHproductions Not sure if I understand your suggestion correctly. I think &D needs to be after t because the second part of the displayed output needs to be without quotes – Luis Mendo – 2016-10-23T03:00:37.903

1I mean that unevaling the string &D and then re-evaling U seems a little redundant. It's probably not shorter any other way, though, as you would likely need to use stack manipulation. – ETHproductions – 2016-10-23T03:03:32.957

@ETHproductions Oh, now I see what you mean: this, right? (w is swap). As you say, it's not shorter unfortunately

– Luis Mendo – 2016-10-23T03:08:14.197

Yeah, that's what I meant, and that's what I figured – ETHproductions – 2016-10-23T03:09:41.540

Shouldn't this be 12 bytes, since there's a trailing newline in the output? – Conor O'Brien – 2018-06-01T19:32:03.053

@ConorO'Brien I think so, yes. Thanks! – Luis Mendo – 2018-06-01T21:13:01.963

3

Rust, 173 158 152 144 137 102 bytes

Tuples plus Rust's debug printing mechanism ( {:?} in a format string ) let me cut it down 30+ characters!

fn main(){let t=("fn main(){let t=", ";print!(\"{}{:?}{}\",t.0,t,t.1)}");print!("{}{:?}{}",t.0,t,t.1)}

Pretty-printed. It's so small there's little left to explain!

fn main() {
    // The space after the comma is necessary, because that's how
    // debug-print formats tuples
    let t=("fn main(){let t=", ";print!(\"{}{:?}{}\",t.0,t,t.1)}");
    print!("{}{:?}{}",t.0,t,t.1)
}

Harald Korneliussen

Posted 2011-01-28T00:34:05.293

Reputation: 430

2

Pushy, 9 bytes

95 34
_"

(non-competing as the language postdates the challenge)

Although writing functional programs in Pushy is sometimes difficult, the quine is relatively simple:

95   % Push 95 to the stack (ASCII code for _ )
34   % Push 34 to the stack (ASCII code for " )
_    % Print representation of the stack: 95 34
"    % Print stack converted to string: _"

Notice that, although Pushy ignores newlines, it is needed here because the default separator for printing is \n - and there needs to be a trailing newline, hence making it 9 bytes


Alternatively, an 11-byte solution that does not require a newline:

78 95 34N_"

Works similarly to the one above, but N sets the separator an empty string.

FlipTack

Posted 2011-01-28T00:34:05.293

Reputation: 13 242

2

V, 4 bytes

2i2i

Try it online!

Marked as non-competing because this language postdates the challenge by several years.

Explanation:

2       " Two times:
 i      " Insert the following:
  2i    " The string '2i'

This is pretty straightforward. In fact, this almost works in regular vim. There is just one minor thing in the way: The string '2i' isn't inserted twice until you hit <esc>. In V, this is solved by implicitly ending every program with an <esc> (Really, that's an oversimplification, but it's close enough to the truth).

Old versions of V always added a newline to the output, which is why I didn't post this earlier. However, in commit b6c238d, this was fixed.

This answer works just because of luck. The approach doesn't extend well to general purpose quines/quine-variations. The shortest quine I'm aware of that can be trivially modified is

ñéÑ~"qpÿ

Try it online!

Explanation:

ñ           " Start recording into register 'q'
 éÑ         " Insert 'Ñ' (uppercase so that the recording doesn't stop here)
   ~        " Toggle the case the character under the cursor (the 'Ñ')
    "qp     " Paste the contents of register 'q'
       ÿ    " Stop recording and play it all back

The reason the ÿ is needed, is because it is implicitly added to the end of macros, a feature that is unfortunate for quines, but very convenient for golf.

The nice thing about this quine is that we can do almost anything inside of the recording and it is still valid since it will be pasted later anyway.

James

Posted 2011-01-28T00:34:05.293

Reputation: 54 537

2

Cheddar, 56 bytes

Try this one online!

let q='let q=%s%s%s;print IO.sprintf(q,@"39,q,@"39)';print IO.sprintf(q,@"39,q,@"39)

See the explanation below, except mentally replace % with IO.sprintf.




Well darn. @ETHProductions came up with this solution before me..

This is the shortest I could come up with... Maybe some abuse of functional operators could help me.

let q='let q=%s;print q%@"39+q+@"39';print q%@"39+q+@"39

Try it online! You can guess what the output is.

This code can be divided into two parts: the string and the output. The string part:

let q='let q=%s;print q%@"39+q+@"39';

is simply a formatting template.

The output part:

;print q%@"39+q+@"39

formats the string. @"39 is char 39, or '.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2

Java 8, 94 bytes

()->{String s="()->{String s=%c%s%1$c;System.out.printf(s,34,s);}";System.out.printf(s,34,s);}

This is a lambda expression which prints its own source code to STDOUT. It uses a similar tactic to other Java quines here, but the lambda really helps cut down bytes.

If we wanted to be really cheeky and cut down two bytes, we could declare the lambda as x->, where x is an empty string, as according to meta, "taking no input" means you can assume empty input, and in function submissions input is given as a parameter.

FlipTack

Posted 2011-01-28T00:34:05.293

Reputation: 13 242

2

Python 3, 38 bytes

There are already a lot of Python quines, but as far as I can see this one hasn't been posted yet. Technically it is a statement that evaluates to a string representation of itself, but other submissions do similar things.

'.__repr__()[:-1]*2'.__repr__()[:-1]*2

This works in a similar way to many quines in 2D langauges with "edge-wrap", where "string mode" is entered, the whole program is pushed to the stack, then string mode is executed and the program runs, printing the string mode character (usually ") followed by the contents of the stack (i.e. the program's source) then exiting.

A breakdown of the statement is as follows:

'.__repr__()[:-1]*2'                   # A string containing the body of the program.
                                       # .__repr__()[:-1]*2
                    .__repr__()        # The same string, but enclosed in single quote marks.
                                       # '.__repr__()[:-1]*2'
                               [:-1]   # A splice that crops off the last character.
                                       # '.__repr__()[:-1]*2
                                    *2 # Repeat the string.
                                       # '.__repr__()[:-1]*2'.__repr__()[:-1]*2

The reason I have used .__repr__() instead of repr(string) is because the quine relies on code following and not preceding the string. This is also why this is a statement and not a program; the print() function requires code before the string, which is not possible with this quine layout.

As you may have noticed, there's a much golfier statement that evaluates to this statement:

"'.__repr__()[:-1]*2"*2

But this isn't a quine, because it doesn't evaluate to itself.

wizzwizz4

Posted 2011-01-28T00:34:05.293

Reputation: 1 895

1Unfortunately, I don't think this is valid, since it's an expression (and therefore a snippet) rather than a full program. – Esolanging Fruit – 2017-07-30T02:33:17.127

2

Threead, 101 bytes

>91>60>93>62>91>105>54>50>99>111>100>111>62>93>60>91>60>93>62>91>99>111>62>93[<]>[i62codo>]<[<]>[co>]

Try it online!

My first thought for writing a Threead quine was to store the entire data section as one large number, in order to get a good compression ratio. This doesn't work because a) % appears to be broken, and b) Threead doesn't support bignum arithmetic.

Instead, I wrote this solution, which works along the same lines as a brainfuck quine, storing the characters of the code section of the program as individual tape elements. Then we just have to scan the list once in order to print it as data, and again to print it as code.

Although Threead allows for three threads, and requires their use when performing binary operations, this style of quine uses only unary operations and thus there was no point in using more than one thread, so I just did everything inside the first.

Explanation

>91>60>…>62>93            ASCII character codes of the rest of the program
[<]>                      Return the pointer to the start of the data
[                         While the current data cell is nonzero:
 i62                        Place 62 (ASCII code of >) on a temporary tape cell
 co                         Output it as a character (i.e. >)
 d                          Delete the temporary tape cell
 o                          Output the current data element as an integer
>]                        then continue the loop with the next data cell
<[<]>                     Return the pointer to the start of the data
[                         While the current data cell is nonzero:
 co                         Output it as a character
>]                        then continue the loop with the next data cell

user62131

Posted 2011-01-28T00:34:05.293

Reputation:

Nice. Basically the same as mine but with > at the beginning. I like it

– Riley – 2017-01-16T23:01:00.467

I hope you don't mind that I used that trick in my new version :) – Riley – 2017-01-16T23:23:54.583

@Riley: That's OK, we're pretty much all cooperating to improve the quine at this point. – None – 2017-01-16T23:25:03.443

2

SmileBASIC, 66 54 bytes

?MID$(("+CHR$(34))*3,19,54)?MID$(("+CHR$(34))*3,19,54)

This will work in most BASIC dialects.

12Me21

Posted 2011-01-28T00:34:05.293

Reputation: 6 110

2

Alice, 9 bytes

Credits to Sp3000 for the idea of including the !.

"!<@o&9h.

Try it online!

Explanation

This works much like quines in other Fungeoids with an unmatched " that wraps the entire code (except itself) in a string because the instruction pointer move cyclically through the code.

"!<@o&9h."   Push code points of the entire program except the " to the
             stack (irrelevant).
!            Store 46 (the code point of '.') on the tape (irrelevant).
<            Send IP back west.
!            Store 104 (the code point of 'h') on the tape (irrelevant).
".h9&o@<!"   Push code points of the entire program except the " to the
             stack in reverse.
.            Duplicate the 33 (the code point of '!').
h            Increment to 34 (the code point of '"').
             Now the top nine values on the stack correspond to the entire
             code in reverse order.
9&           Repeat the next command 9 times.
o            Print 9 characters from the top of the stack.
@            Terminate the program.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

2

Ohm, 22 20 bytes

-2 bytes thanks to Business Cat

"D34'DLaJL"D34'DLaJL

Try it online!

"D34'DLaJL"          # Push this string (everything after this)
           D         # Duplicate
            34'      # Push the character "
               D     # Duplicate
                L    # Print "
                 a   # Swap the top 2 elements 
                  JL # Print the string, ", then the string again.

Riley

Posted 2011-01-28T00:34:05.293

Reputation: 11 345

You can save 2 bytes by replacing LLL with JL (in both occurrences). – Business Cat – 2017-05-18T17:56:58.027

2

x86/DOS assembly, 4619 bytes

bits 16
org 256
mov ah,64
mov bx,1
mov cx,720
mov dx,b+16
int 33
mov cx,90
mov si,b+16
c:push cx
mov ah,64
mov bx,1
mov cx,6
mov dx,b
int 33
mov cx,7
a:push cx
mov al,[si]
shr al,4
add al,48
cmp al,58
jb g
add al,39
g:mov [b+8],al
lodsb
and al,15
add al,48
cmp al,58
jb e
add al,39
e:mov [b+9],al
mov ah,64
mov bx,1
mov cx,5
mov dx,b+6
int 33
pop cx
loop a
mov al,[si]
shr al,4
add al,48
cmp al,58
jb h
add al,39
h:mov [b+8],al
lodsb
and al,15
add al,48
cmp al,58
jb n
add al,39
n:mov [b+9],al
mov ah,64
mov bx,1
mov cx,4
mov dx,b+6
int 33
pop cx
loop c
mov ah,64
mov bx,1
mov cx,5
mov dx,b+11
int 33
mov ah,76
int 33
b   db 13,10,' db 0x  ,',13,10,'end'
 db 0x62,0x69,0x74,0x73,0x20,0x31,0x36,0x0d
 db 0x0a,0x6f,0x72,0x67,0x20,0x32,0x35,0x36
 db 0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x61,0x68
 db 0x2c,0x36,0x34,0x0d,0x0a,0x6d,0x6f,0x76
 db 0x20,0x62,0x78,0x2c,0x31,0x0d,0x0a,0x6d
 db 0x6f,0x76,0x20,0x63,0x78,0x2c,0x37,0x32
 db 0x30,0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x64
 db 0x78,0x2c,0x62,0x2b,0x31,0x36,0x0d,0x0a
 db 0x69,0x6e,0x74,0x20,0x33,0x33,0x0d,0x0a
 db 0x6d,0x6f,0x76,0x20,0x63,0x78,0x2c,0x39
 db 0x30,0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x73
 db 0x69,0x2c,0x62,0x2b,0x31,0x36,0x0d,0x0a
 db 0x63,0x3a,0x70,0x75,0x73,0x68,0x20,0x63
 db 0x78,0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x61
 db 0x68,0x2c,0x36,0x34,0x0d,0x0a,0x6d,0x6f
 db 0x76,0x20,0x62,0x78,0x2c,0x31,0x0d,0x0a
 db 0x6d,0x6f,0x76,0x20,0x63,0x78,0x2c,0x36
 db 0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x64,0x78
 db 0x2c,0x62,0x0d,0x0a,0x69,0x6e,0x74,0x20
 db 0x33,0x33,0x0d,0x0a,0x6d,0x6f,0x76,0x20
 db 0x63,0x78,0x2c,0x37,0x0d,0x0a,0x61,0x3a
 db 0x70,0x75,0x73,0x68,0x20,0x63,0x78,0x0d
 db 0x0a,0x6d,0x6f,0x76,0x20,0x61,0x6c,0x2c
 db 0x5b,0x73,0x69,0x5d,0x0d,0x0a,0x73,0x68
 db 0x72,0x20,0x61,0x6c,0x2c,0x34,0x0d,0x0a
 db 0x61,0x64,0x64,0x20,0x61,0x6c,0x2c,0x34
 db 0x38,0x0d,0x0a,0x63,0x6d,0x70,0x20,0x61
 db 0x6c,0x2c,0x35,0x38,0x0d,0x0a,0x6a,0x62
 db 0x20,0x67,0x0d,0x0a,0x61,0x64,0x64,0x20
 db 0x61,0x6c,0x2c,0x33,0x39,0x0d,0x0a,0x67
 db 0x3a,0x6d,0x6f,0x76,0x20,0x5b,0x62,0x2b
 db 0x38,0x5d,0x2c,0x61,0x6c,0x0d,0x0a,0x6c
 db 0x6f,0x64,0x73,0x62,0x0d,0x0a,0x61,0x6e
 db 0x64,0x20,0x61,0x6c,0x2c,0x31,0x35,0x0d
 db 0x0a,0x61,0x64,0x64,0x20,0x61,0x6c,0x2c
 db 0x34,0x38,0x0d,0x0a,0x63,0x6d,0x70,0x20
 db 0x61,0x6c,0x2c,0x35,0x38,0x0d,0x0a,0x6a
 db 0x62,0x20,0x65,0x0d,0x0a,0x61,0x64,0x64
 db 0x20,0x61,0x6c,0x2c,0x33,0x39,0x0d,0x0a
 db 0x65,0x3a,0x6d,0x6f,0x76,0x20,0x5b,0x62
 db 0x2b,0x39,0x5d,0x2c,0x61,0x6c,0x0d,0x0a
 db 0x6d,0x6f,0x76,0x20,0x61,0x68,0x2c,0x36
 db 0x34,0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x62
 db 0x78,0x2c,0x31,0x0d,0x0a,0x6d,0x6f,0x76
 db 0x20,0x63,0x78,0x2c,0x35,0x0d,0x0a,0x6d
 db 0x6f,0x76,0x20,0x64,0x78,0x2c,0x62,0x2b
 db 0x36,0x0d,0x0a,0x69,0x6e,0x74,0x20,0x33
 db 0x33,0x0d,0x0a,0x70,0x6f,0x70,0x20,0x63
 db 0x78,0x0d,0x0a,0x6c,0x6f,0x6f,0x70,0x20
 db 0x61,0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x61
 db 0x6c,0x2c,0x5b,0x73,0x69,0x5d,0x0d,0x0a
 db 0x73,0x68,0x72,0x20,0x61,0x6c,0x2c,0x34
 db 0x0d,0x0a,0x61,0x64,0x64,0x20,0x61,0x6c
 db 0x2c,0x34,0x38,0x0d,0x0a,0x63,0x6d,0x70
 db 0x20,0x61,0x6c,0x2c,0x35,0x38,0x0d,0x0a
 db 0x6a,0x62,0x20,0x68,0x0d,0x0a,0x61,0x64
 db 0x64,0x20,0x61,0x6c,0x2c,0x33,0x39,0x0d
 db 0x0a,0x68,0x3a,0x6d,0x6f,0x76,0x20,0x5b
 db 0x62,0x2b,0x38,0x5d,0x2c,0x61,0x6c,0x0d
 db 0x0a,0x6c,0x6f,0x64,0x73,0x62,0x0d,0x0a
 db 0x61,0x6e,0x64,0x20,0x61,0x6c,0x2c,0x31
 db 0x35,0x0d,0x0a,0x61,0x64,0x64,0x20,0x61
 db 0x6c,0x2c,0x34,0x38,0x0d,0x0a,0x63,0x6d
 db 0x70,0x20,0x61,0x6c,0x2c,0x35,0x38,0x0d
 db 0x0a,0x6a,0x62,0x20,0x6e,0x0d,0x0a,0x61
 db 0x64,0x64,0x20,0x61,0x6c,0x2c,0x33,0x39
 db 0x0d,0x0a,0x6e,0x3a,0x6d,0x6f,0x76,0x20
 db 0x5b,0x62,0x2b,0x39,0x5d,0x2c,0x61,0x6c
 db 0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x61,0x68
 db 0x2c,0x36,0x34,0x0d,0x0a,0x6d,0x6f,0x76
 db 0x20,0x62,0x78,0x2c,0x31,0x0d,0x0a,0x6d
 db 0x6f,0x76,0x20,0x63,0x78,0x2c,0x34,0x0d
 db 0x0a,0x6d,0x6f,0x76,0x20,0x64,0x78,0x2c
 db 0x62,0x2b,0x36,0x0d,0x0a,0x69,0x6e,0x74
 db 0x20,0x33,0x33,0x0d,0x0a,0x70,0x6f,0x70
 db 0x20,0x63,0x78,0x0d,0x0a,0x6c,0x6f,0x6f
 db 0x70,0x20,0x63,0x0d,0x0a,0x6d,0x6f,0x76
 db 0x20,0x61,0x68,0x2c,0x36,0x34,0x0d,0x0a
 db 0x6d,0x6f,0x76,0x20,0x62,0x78,0x2c,0x31
 db 0x0d,0x0a,0x6d,0x6f,0x76,0x20,0x63,0x78
 db 0x2c,0x35,0x0d,0x0a,0x6d,0x6f,0x76,0x20
 db 0x64,0x78,0x2c,0x62,0x2b,0x31,0x31,0x0d
 db 0x0a,0x69,0x6e,0x74,0x20,0x33,0x33,0x0d
 db 0x0a,0x6d,0x6f,0x76,0x20,0x61,0x68,0x2c
 db 0x37,0x36,0x0d,0x0a,0x69,0x6e,0x74,0x20
 db 0x33,0x33,0x0d,0x0a,0x62,0x20,0x20,0x20
 db 0x64,0x62,0x20,0x31,0x33,0x2c,0x31,0x30
 db 0x2c,0x27,0x20,0x64,0x62,0x20,0x30,0x78
 db 0x20,0x20,0x2c,0x27,0x2c,0x31,0x33,0x2c
 db 0x31,0x30,0x2c,0x27,0x65,0x6e,0x64,0x27
end

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

2

ACL2, 41 bytes

(let((q"(let((q~x0))(cw q q))"))(cw q q))

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

2

ABAP, 515 bytes

REPORT R NO STANDARD PAGE HEADING.DATA:A TYPE TABLE OF STRING,B(8).APPEND:
`REPORT.FORM F TABLES T.NEW-PAGE LINE-SIZE 78.WRITE:'REPORT R NO',` TO A,
`'STANDARD PAGE HEADING.DATA:A TYPE TABLE OF STRING,B(8).APPEND:'.LOOP` TO A,
`AT T.REPLACE ALL OCCURENCES OF'``' IN T WITH'````'.WRITE:/'``'` TO A,
`NO-GAP,T NO-GAP,'`` TO A,'.ENDLOOP.WRITE:AT 78'.','GENERATE',` TO A,
`'SUBROUTINE POOL A NAME B.PERFORM F IN PROGRAM (B) TABLES A.'.ENDFORM.` TO A.
GENERATE SUBROUTINE POOL A NAME B.PERFORM F IN PROGRAM (B) TABLES A.

Should work on on any SAP system with SY-SAPRL >= '700'.

source

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

is this an error quine? – Destructible Lemon – 2017-05-24T23:53:22.123

@DestructibleLemon No, why do you ask? – MD XF – 2017-05-25T00:46:19.537

Anyone care to explain the serial downvoting? – MD XF – 2017-05-25T17:20:35.533

2

Excel, 131 bytes

=SUBSTITUTE("=SUBSTITUTE(@,CHAR(64),CHAR(34)&@&CHAR(34))",CHAR(64),CHAR(34)&"=SUBSTITUTE(@,CHAR(64),CHAR(34)&@&CHAR(34))"&CHAR(34))

Adapted from a program by Dave Burt.

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

2

Go, 112 bytes

As far as I can tell, there's no Go answer here. Here's mine and I think this is the shortest possible.

package main;import.`fmt`;func main(){s:="package main;import.`fmt`;func main(){s:=%q;Printf(s,s)}";Printf(s,s)}

Try it online!

totallyhuman

Posted 2011-01-28T00:34:05.293

Reputation: 15 378

2

QBIC, 8 bytes

?A+@?A+@

I was trying to do this, but I accidentally golfed an actual quine. Whadda you know?

Explanation

?           Print
 A            A$
  +         concatenated with
   @       a string literal containing
    ?A+@   "?A+@"

When A$ is used the first time, it might not seem to have a value yet, but it already contains the string literal ?A+@ because the QBIC interpreter first scans the code, sees the @, looks up what the first available string variable is (it's A$, because it hasn't been used by other QBIC language features yet), and it then extracts the definition A$ = "?A+@" to the top of the file, and inserts A$ at the place where it found the literal.

steenbergh

Posted 2011-01-28T00:34:05.293

Reputation: 7 772

2

Micro, 5 bytes

{_BS}

Explination:

{_BS}

{      start a code block (this block will be run due to implicit evaluation)
 _     push the item most recently popped. this pushes the code block which was popped due to implicit evaluation
  BS}  convert the code block to a string, and end the block. Micro's implicit evaluation is weird, because the evaluated variable may generate new items on the stack, in which case the program's execution will continue as if it hadn't ended. this second implicit evaluation displays the string which is left on the stack: "{_BS}", and ends execution.

raddish0

Posted 2011-01-28T00:34:05.293

Reputation: 91

2

JScript, 175 bytes

WScript.Echo((k="WScript.Echo((k=\"%Z\").replace(/%[Z]/,k.replace(/[\"\\\\]/g,function(e){return\"\\\\\"+e})))").replace(/%[Z]/,k.replace(/["\\]/g,function(e){return"\\"+e})))

JScript is Microsoft's implementation of the JavaScript language. On a microsoft console, you can invoke the program as <name>.js, and this will output to a popup. To output to the console, one must use:

cscript //E:JScript //nologo <name>.js

and add a trailing CRLF to the source code.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2

Foam, 15 bytes

[. <' |: ~|]: ~

This prints itself with a trailing newline. Without a trailing newline:

[. .' |: ~|]: ~

Esolanging Fruit

Posted 2011-01-28T00:34:05.293

Reputation: 13 542

2

Gaia, 10 bytes

“:ṙpp”:ṙpp

Try it online!

Explanation

“:ṙpp”      Push this string.
      :     Copy it.
       ṙ    Get the string representation of it.
        p   Print the string representation.
         p  Print the string.

Business Cat

Posted 2011-01-28T00:34:05.293

Reputation: 8 927

2

PHP, 50 chars

<?printf($s='<?printf($s=%c%s%1$c,39,$s);',39,$s);

I realized I could save four chars by enabling short tags (<?=sprintf becomes <?printf)

I saved four more bytes by reusing one of the values in my printf.

Umbrella

Posted 2011-01-28T00:34:05.293

Reputation: 867

2

Proton, 32 30 bytes

-2 bytes thanks to ppperry.

s='s=%rprint(s%%s)'print(s%s)

Try it online!

I swear, if I get a bounty for this...

totallyhuman

Posted 2011-01-28T00:34:05.293

Reputation: 15 378

Hey, I promised a bounty, so if nobody beats it, good for you I guess :P – HyperNeutrino – 2017-08-17T19:39:38.840

1You can save two bytes by deleting the semicolons – pppery – 2017-08-18T22:18:16.503

2

C (tcc), 64 bytes

main(t){printf(t,34,t="main(t){printf(t,34,t=%c%s%c,34);}",34);}

Try it online!

could be one problem if compiler not use the stack based way of push arguments.
result of the print (tcc, gcc all in TIO today at last ok (not ok in clang)):

main(t){printf(t,34,t="main(t){printf(t,34,t=%c%s%c,34);}",34);}

RosLuP

Posted 2011-01-28T00:34:05.293

Reputation: 3 036

Related – No one – 2017-12-23T19:09:37.610

2

MaybeLater, 74 bytes

x="write(('x='+chr(34))+x+(chr(34))+x)"write(('x='+chr(34))+x+(chr(34))+x)

Try it online!

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

2

Java 8 - 392 bytes

interface Q{static void main(String[]a){p("interface Q{static void main(String[]a){p(");q(");}static void p(String s){System.out.print(s+(char)34+s+(char)34+')'+';'+'q'+'('+(char)34);}static void q(String s){System.out.print(s+(char)34+s);}}");}static void p(String s){System.out.print(s+(char)34+s+(char)34+')'+';'+'q'+'('+(char)34);}static void q(String s){System.out.print(s+(char)34+s);}}

The main trick with this was using 34 cast to a character for the quotes that bound the string literals in order to not run into issues.

the_evictor

Posted 2011-01-28T00:34:05.293

Reputation: 21

3Welcome to PPCG! – Steadybox – 2018-01-09T15:53:52.203

2

Wumpus, 9 bytes

"#34#9&o@

Try it online!

Explanation

This is a fairly standard Fungeoid quine. However, as opposed to most other Fungeoids, Wumpus's grid doesn't wrap around, so the IP actually bounces back and forth through the code:

"#34#9&o@o&9#32#"
     This pushes the individual code points of this string to the stack.
#34  Push 34.
#9   Push 9.
&o   Print 9 characters from the top of the stack.
@    Terminate the program.

There are several other ways to do this in 9 bytes, e.g. this one which generates the " from the # instead:

"#9[(~&o@

I haven't yet found a way to get it down to 8 bytes though (it might be possible: if there's a way to generate the 34 in three bytes that doesn't end in a digit, we could get rid of the # in front of the 9).

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

2

Rust, 108 characters

macro_rules!f(()=>("macro_rules!f(()=>({:?}));fn main(){{print!(f!(),f!())}}"));fn main(){print!(f!(),f!())}

This is a suboptimal solution, but it's so close to the current shortest solution that I wanted to post it anyway as it uses a completely different strategy. I think it can be optimized by using macro keyword instead of verbose macro_rules! when it becomes stable (which would reduce this to 96 characters).

Konrad Borowski

Posted 2011-01-28T00:34:05.293

Reputation: 11 185

2

Pari/GP, 29 bytes

(f=()->print1("(f="f")()"))()

Try it online!

alephalpha

Posted 2011-01-28T00:34:05.293

Reputation: 23 988

2

Swift 4, 63 bytes

let s=[";print(\"let s=\\(s)\"+s[0])"];print("let s=\(s)"+s[0])

Try it online!

Herman L

Posted 2011-01-28T00:34:05.293

Reputation: 3 611

2

Gol><>, 6 5 bytes

sP#H"

Try it online!

Credit to Jo King.

How it works

sP#H"

s      +16
 P     +1
  #    Reverse direction
 P     +1
s      +16
    "  Start string literal
sP#H"  Push H, #, P, s and end string literal
   H   Print everything on the stack from the top, and halt
       The printed chars are s, P, #, H, 34 (")

Previous solution, 6 bytes

"r2ssH

Try it online!

How it works

"r2ssH  Push the string "r2ssH" to stack, "r" being at the bottom
"       Close the literal
 r      Reverse the stack
  2ss   Push 34 (")
     H  Print all content of the stack from top to bottom as chars, and halt

There were a couple of alternatives to consider:

  • S" prints the string right away (instead of pushing to stack), but then it gets harder to handle ".
  • `" is an alternative way to push 34 to the stack, but the string literal also treats `" as escaped " which is not desirable.

Bubbler

Posted 2011-01-28T00:34:05.293

Reputation: 16 616

An interesting 8 byter using S"

– Jo King – 2018-11-28T00:34:06.217

2

Cardinal, 10 bytes

",-#) %8-$

Try it online!

This should be a quine, except for a small bug in the interpreter which causes the ( command to throw an error. For completeness' sake, here's a version where a # is placed in the position the ( is accidentally calling. Note that the space is actually a NUL character. Bug is fixed, yay!

"% (#-,0-$ also works with just one pointer.

How It Works:

The % creates two pointers, going left and right (the ones going vertical don't matter). The right pointer is delayed by the 8 for three steps, which lets the left pointer execute ,-#) which changes the active value to #, decrements it and prints the ". Then the right pointer starts again, decrementing the active value to -1. $ sets the pointer location to 0,-1, which then runs " over the rest of the code, printing it.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

1

You can download fixed and recompiled version (including source code) of the interpreter from my Github repo: https://github.com/m-lohmann/Cardinal. The original interpreter had several errors that needed fixing.

– M L – 2018-06-02T00:08:19.077

I don't think your last edit worked properly, the URLs are identical. – Ørjan Johansen – 2018-09-05T18:11:37.667

@Orjan lol, it seems I had already made the exact change in a previous edit. – Jo King – 2018-09-07T13:30:39.460

2

Nim, 95 bytes

import strutils;let s="import strutils;let s=$#;echo s%s.repr[^49..^1]";echo s%s.repr[^49..^1]

Try it online!

After scrolling through the leaderboard snippet, I was surprised to see that Nim hasn't been represented here yet. So, let's fix it!

This follows the standard pattern of constructing and printing a string with a quoted representation of itself inserted in the middle. Unfortunately, Nim has a few features that make this golf-unfriendly:

  • String interpolation with % is not available unless you import strutils.
  • repr not only quotes strings, but also prepends them with a hex number (seemingly, memory address), like this: 0x40a6d0"my string". Therefore, we have to extract the right part.

Still, not so bad overall, as it is significantly shorter than the version currently posted at Rosetta Code, which actually doesn't even work without tweaks in recent versions of the language.

Kirill L.

Posted 2011-01-28T00:34:05.293

Reputation: 6 693

var x="var x=;echo x[0..5],x.repr[14..^1],x[6..^1]";echo x[0..5],x.repr[14..^1],x[6..^1] – ASCII-only – 2019-08-27T03:25:47.790

2

J, 27 bytes

echo(,quote)'echo(,quote)'

Try it online!

It's surprising that there's no proper J quine submission yet.

How it works

echo(,quote)'echo(,quote)'
            'echo(,quote)'  The string `s`
      quote                 Wrap `s` with single quotes
     ,                      Concat s to the above; `(f g)x` is equal to `x f g x`
echo                        Explicitly print the result

echo is needed because the result of a non-REPL line is not printed.

Bubbler

Posted 2011-01-28T00:34:05.293

Reputation: 16 616

2

Backhand, 21 bytes

"#v{<@^:[ba+0v|{$:o[}

Try it online!

This is my new 1D language Backhand. It's a little bit more complicated than the typical wrapping string literal quine.

Explanation:

The program initially starts with a step count of 3.

"      Start string literal, stepping 3 places at a time
       This pushes the source code, but all jumbled up :(

See my Hello, World! answer to see what you have to do to push a string normally.

"      End the garbage string literal
  v{   Step left and decrease the step count to 2
    <  Change direction to left
  v    Decrease the step count to 1
 #     No-op
"      Start string literal
       Now the step count is 1, so it actually pushes the source code
 #v{<@^:[ba+0v|{$:o[}    Push to stack going right and bounce off the end
 #v{<@^:[ba+0v|{$:o[     Push to stack going left
"      End string literal
  v    Decrease the step count to 0
  v    Decrease the step count to -1
       Now the pointer is technically going right, but with a step count of -1
"      Push the source code again...
  v    Decrease the step count to -2
    <  Change direction to left (step count is still negative, so it goes right)

      ^           Increase step count to -1
       :[         Dupe the top of stack (# 35) and decrement to 34 (")
         ba+      Add 10 and 11 to push 21 as the counter
            0     Push 0
             v    Decrease step count to -2
               {  Step left
              |   Pop 0 and continue moving left
                $ o    Swap the top two items and print the character
                   [}  Step right (against the wall so it bounces) and decrement the counter
              |{ :     Duplicate the counter and reflect if it is non-zero
                       Repeat this 21 times to print the source code
        [ a 0  Garbage
      ^        Increase the step counter to -1
     @         Terminate program

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

2

Elixir, 44 bytes

q=:'q=:~p;:io.format q,[q]';:io.format q,[q]

Try it online!

This is basically an existing quine taken from here, but I managed to save another 2 bytes by declaring q as an atom instead of a binary.

Kirill L.

Posted 2011-01-28T00:34:05.293

Reputation: 6 693

2

33, 26 bytes

"34cktptptptp"34cktptptptp

Try it online!

Explanation:

"34cktptptptp"             (The instructions)
              34ck         (Load 34 (") into destination string)
                  tp       (Print it)
                    tp     (Print the instructions)
                      tptp (Repeat)

TheOnlyMrCat

Posted 2011-01-28T00:34:05.293

Reputation: 1 079

2

Corea, 11 bytes

<0C>;"<0C>;

Try it online!

Alternatively, <0C>>"<0C>>

<0C>;"<0C>;
<0C>;            set the contents to that literal string
     "           start command sequence
      <          push a copy of the contents to the stack
       0C        push a quote "
         >       append that to the contents
          ;      and append the original copy and stop command sequence

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2

Tir, 24 bytes

Abandoned languages are my favorite.

«⤇℘↔»
⤇℘↔

Explanation

«⤇℘↔»       Push a string onto the stack. Stack: [⤇℘↔]
      ⤇      Duplicate TOS. Stack: [⤇℘↔,⤇℘↔]
        ℘    Make top of stack in its string-represented form. Stack: [⤇℘↔,«⤇℘↔»]
         ↔   Swap top two items in the stack. Stack: [«⤇℘↔»,⤇℘↔]
Stack will be implicitly outputted.

user85052

Posted 2011-01-28T00:34:05.293

Reputation:

2

Alchemist, 299 bytes

_->14733272090064622117723033634640281434301133345502153207896692199003336573010981052872005814325038964478266287468505274190371239580629370336756929651609657090021232407437472153714372752689076920028135a+Out_"_->"+Out_a+d
d+0e->118b
a+b->o
118o->c+d
0a+0e+c->Out'o+e
e+b->e+o
e+d+c->e+d+a
0c+e+d->d

Try it online!

I'm posting this as a separate answer to my existing one since it uses newer features (character output). This functions much the same but with less logic regarding the modulo values, countered partially by the number being in base 118 instead of base 9. Here is an encoder that can be used to encode the large number up front.

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

2

Poetic, 2100 1896 bytes

-204 bytes by using ASCII 255 and 1 instead of ASCII 122 and 123.

ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿ ÿ ÿÿÿÿÿÿ ÿ ÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿ ÿÿ ÿÿÿ ÿ ÿÿÿÿÿÿ ÿÿÿ ÿ ÿÿÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿÿ ÿÿ ÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿ ÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿ ÿÿÿÿÿÿ ÿ ÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿ ÿ ÿ ÿÿÿÿÿ ÿ ÿÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿÿÿÿ ÿÿÿÿÿ ÿÿ ÿÿÿ ÿÿÿ ÿ ÿÿÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿÿ ÿÿ ÿÿ ÿÿÿÿÿ ÿÿÿ ÿ ÿÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿÿ ÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿÿ ÿ ÿÿÿÿÿÿ ÿ ÿ ÿÿÿÿÿ ÿ ÿÿÿÿÿÿÿ ÿÿÿÿÿÿ ÿ ÿÿÿÿ ÿ ÿÿ ÿÿÿÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿÿÿ ÿÿÿÿÿÿ ÿÿ ÿÿ 

(All of the space characters are actually ASCII code 1, or SOH. StackExchange doesn't seem to like unprintables all that much.)

Try it online!

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.

This isn't a terribly Poetic program (it's only two distinct characters), but it's the most compact solution for writing commands that I was able to come up with.

Basically, the core of the program is code that takes tape values corresponding to Poetic commands in a line, adds values to the beginning that would put these values on the tape when executed, and then outputs the values as Poetic commands. The initial values on the tape are, of course, an encoded version of that code. (Standard stuff, surely, but it took me a while to wrap my head around it.)

JosiahRyanW

Posted 2011-01-28T00:34:05.293

Reputation: 2 600

2

Zozotez Lisp: 73

((\ (x) (c x (c (c (" ") (c x))))) (" (\ (x) (c x (c (c (" ") (c x)))))))

This requires one of the REPLs. For one bootstrap expression quine I need it to print: 81

((\ (x) (p (c x (c (c (" ") (c x)))))) (" (\ (x) (p (c x (c (c (" ") (c x))))))))

Extended BrainFuck: 68

This uses mostly Brainfuck code except for the store string procedure.

>~"~!<<.[<]>.>+.-<[.>]<[<]>>+.->[.>]"<<.[<]>.>+.-<[.>]<[<]>>+.->[.>]

A 94 byte version that uses more EBF features:

{c|"{q$q.$p(-)}:q:p$q 34+$p|'{c|'&q&c&q|'}'(-)&c"}{q$q.$p(-)}:q:p$q 34+$p|'{c|'&q&c&q|'}'(-)&c

Sylwester

Posted 2011-01-28T00:34:05.293

Reputation: 3 678

2

Unary, ~6.1*10^4391 bytes

000000000...(more 0s than fits in the observable universe)...000

For reasons that may be somewhat obvious, you can't try this one online.

What the hell is Unary?

Unary is a joke(?) esolang with a pretty basic premise: the only valid symbol is the number 0. To interpret Unary, the 0s are first counted, then that number is converted into binary, then that number is converted into brainfuck (000 corresponds to +, 001 corresponds to -, and so on), then the brainfuck is run.

It's worth noting that you can't distinguish between the numbers 000001 and 001 even though they represent different brainfuck, so in all cases, Unary requires us to include an extra 1 bit at the top of the binary representation: we instead write the binary numbers 1000001 or 1001, which are distinguishable.

Basic overview/comments

Whew, this was a huge pain. As a forewarning, I'm almost certain it's not optimal (there are quite a few structures that are pretty space-inefficient used in the brainfuck) but I'm also almost certain there's no way this is ever fitting on any real computer, so I don't feel too bad about it.

The basic idea for this is probably about what you expect: there's a big array that represents the rest of the code (with a cell set to negative one at the start for navigation), and there's a bunch of code which takes an array and prints out unary code representing the code initializing the array (and the negative one flag), then the code represented by the array.

Obviously it's impossible to test this thing, but I tested the actual quining part on the smallest possible array input ("->+>>" representing "-++"), and it correctly output exactly 19,407,936 0s (corresponding to "->+>>-++"), which is good enough for me.

Finally, I'd like to point out that this is technically a Unary/Lenguage polyglot quine (as all Unary code is also valid lenguage with the same function), though a proper Lenguage golf adapted from this one would probably be a couple hundred orders of magnitude smaller.

Detailed overview

The core idea of this code is to use our array as a base-8 "number", with each entry being another base-8 "digit". We can cascade this downwards (subtract 1 from an entry and add 8 to the one directly after it), and then print a 0 for every entry in the last array entry. Doing this process on the original array prints Unary code for whatever brainfuck the array represented (the representation is as you might expect: every entry is a different symbol, and every entry contains a number 0-7, one corresponding to each brainfuck command).

You'll note that technically, we're doing this "backwards": printing all the 0s for the code before we print the 0s for the array. I'm not certain that this is necessary, but it does enable us to use some clever constructions later on to save quite a bit of work.

This process, incidentally, will destroy whatever array it's run on. Thus, before we do that, we need to copy the array (actually quite an obnoxious task given that the arrray is variable-length).

Thus after we print the code itself, we have data looking like this:

-1 flag | [original array] | -2 flag | [empty array with the same length] | -3 flag

This means we only need to print the Unary for the array itself, the -1 flag at the start of the array, and the 1 bit at the top of the binary representation which Unary requires.

Fortunately, we can actually use similar code to do this! In order to encode further data, we need to print out 0s in chunks of some very large power of 8: ie, if our code so far was 50 characters long, in order to encode a "-" before the code, we would have to print 8^50 0s.

The power of 8 we have to use is exactly the length of that big empty array. This means that if we put a 1 in the top register of that array, it will increment the last symbol encoded by 1, and if we put an 8 in the top register it will encode a new symbol (specifically a minus).

Furthermore if we move the flag at the end of the array to the right by 1 it'll print out 8 times as many 0s, and thus start editing the symbol before the last symbol encoded!

Since a plus is just "000", we can just move the flag to the right by the value of the last position in the array. This adds as many "000"s to our binary output as there were plusses in the original array representation. When more stuff is added to our array and cascaded down, this will correctly encode the plusses.

We then move the flag at the start of the empty array to the left by 1: this means we start editing the symbol before the plusses we just added. Conveniently, the space it moves into will have been emptied by the operation that moved the end of the array just before now.

All this means that if we put a 2 in the top register of the empty array and then cascade it'll actually print a right carat, and the blank spaces left from moving b will interpret to an appropriate amount of plusses.

We can then repeat this for every single entry in the filled array, thus encoding all of the array representation.

Memory now looks like this

-1 flag|-2 flag| [huge empty array, 2 times as long as the original array]| -3 flag

We now need to add one last minus (to initialize the -1 flag we just got to). All we need to do this is change the minus 2 to a plus 1, then cascade. This both performs the appropriate multiplication by 8, and encodes a -.

Finally, we just need to encode the 1 at the top of the binary representation. To do this, we move b over by 1 one last time and add a 1 at the top, then cascade.

And there it is! We've now printed out 0s representing every part of our original code.

Thank you, and I'm sorry.

Source code

The brainfuck is a little bit long when fully commented (~200 lines), so I'm not certain if I should post it, but I figure y'all can at least have the un-pretty source:

->++>+>+>++>++>+>+>++++++>+>+++>>+++++++>+>++>++++++>>>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>>>++++++>+>+++>>+++++++>+>++>+++++++>>>>++++++>+>+>+>++>>>>+++++++>++>+>+>++++++>+>+++>>+++++++>+>++>+>+>+>+>++>>>++++++>+>+>+++>++>++++++>>>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>>>>>>++++++>+>+>+>+>+++>>>>>+++++++>+>+>+>+>++>+++++++>>>>++++++>+>+>+>++>>>>+++++++>++>>++++++>+>+>+>+>+++>>>>>+++++++>++>+>+>+>+>++>>>+++++++>+>+>+++>>>>>>>>++++++>+>+>+>++>>>>+++++++>+++>+>+>++++++>+>+++>>+++++++>+>++>++>+>+>++++++>+>+>+>++>>>>+++++++>+>+>+>++>++>+>+>++++++>+>+>+++>>>+++++++>+>+>++>++++++>>>>>++++++>+>+>+>+>+>+++>>>>>>+++++++>+>+>+>+>+>+++>>>>>>++++++>+>+>+>+>++>>>>>+++++++>+>+>+>+>+++>>>>++++++>+>+>+++>>>+++++++>+>+>++>+++++++>+>++++++>+>+>+>+>+>+++>>>>>>+++++++>++>+>++++++>+>+>+>+>++>>>>>+++++++>++>>>++++++>+>+>+>+>+>+>+++>>>>>>>+++++++>+>+>+>+>+>+>++>++>>>>++++++>+>+>+>+++>++++++>>>>>++++++>+>+>+>+>+>+++>>>>>>+++++++>+>+>+>+>+>+++>>>>>>++++++>+>+>+>+>++>>>>>+++++++>+>+>+>+>+++>>>>>>>>++++++>+>+>+>+>+>+>+++>>>>>>>+++++++>+>+>+>+>+>+>++>+++++++>>>>>>++++++>+>+>+>+>+>+++>>>>>>+++++++>++>+>++++++>+>+>+>+>++>>>>>+++++++>++>>>++++++>+>+>+>+>+>+>+++>>>>>>>+++++++>++>+>+>+>+>+>+>++>++>>>>+++++++>+>+>+>+++>+++>>>>>>>>>>>>>>++++++>+>+>+>+>+>+>+>+++>>>>>>>>+++++++>>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>++++++>>++++++>+>+>+++>>>+++++++>+>+>+++>>>>>>++++++>+>+>+>+>++>>>>>+++++++>+>+>+>+>+++>>>>>++++++>+>+>+>+++>>>>+++++++>+>+>+>+++>+++++++>++>++>++++++>>++++++>+>+>+++>>>+++++++>+>+>++>>>>>++++++>+>+>+>++>>>>+++++++>+>+>+>++>+++++++>>>++++++>+>+>+++>>>+++++++>+>+>++>++>++>+>+>+>++++++>+>+>+>++>>>>+++++++>+>+>+>++>+>+>+>+>+>++>++>>>>>++++++>+>+>+>+>+++>++++++>>>>>>++++++>+>+>+>+>+>+>+++>>>>>>>+++++++>+>+>+>+>+>+>+++>>>>>>>++++++>+>+>+>+>+>++>>>>>>+++++++>+>+>+>+>+>++>+++++++>>>>>>>++++++>+>+>+>+>+>+>+++>>>>>>>+++++++>++>+>++++++>+>+>+>+>+>++>>>>>>+++++++>++>+>+>+>+>+>++>++>>>>>+++++++>+>+>+>+>+++>+++>>>>>>>>>>>>>>>++++++>+>+>+>+>+>+>+>+>+>+++>>>>>>>>>>+++++++>>++++++>+>+>+>+>++>>>>>+++++++>+>+>+>+>+++>++++++>>>++++++>+>+>+>+++>>>>+++++++>+>+>+>+++>>>>>>++++++>+>+>+>+>++>>>>>+++++++>+>+>+>+>+++>+++++++>>>>++++++>+>+>+>+++>>>>+++++++>+>+>+>++>++>>>>>>>++++++>+>+++>>>>>>>>>++>+++++++>+++>++>+>+>+>+>+>+++>+++>+++>++++++>+>++>++>++++>+++>+++>+++++++>>>>++++++>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>+++>++++++>+>++>++>++>++++>++++>++++>++++>++++>++++>++++>++++>+++>+++>+++>+++++++>>++++++>+>++++++>++>+>++>+++++++>+++>>+++++++>+++>+>++>>>>>>>>>+++>>>>+++++++>+>+>++>+>+>+>+>++++++>+>+>+>+>++>>>>>+++++++>>>>>>++++++>+>+>+>+>+>+++>>>>>>+++++++>>>++++++>+>+>+++>>>+++++++>+>+>+++>>++++++>+>++++++>>>++++++>+>+>+>++>>>>+++++++>+>+>+>++>++++++>+>++>>+++>+++++++>+++>>>>++>+>++++++>+>+>+++>>>+++++++>+>+>+++>+++++++>++>>>+++>+>+>++>>>>>>++++++>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>+++>++++++>+>++>++>++>++++>++++>++++>++++>++++>++++>++++>++++>+++>+++>+++>+++++++>>++++++>+>++++++>++>+>++>+++++++>+++>>+++++++>+++>+>++>>>>>>>>>+++>>>>+++++++>+>+>++>+>+>+>+>+>+>++++++>+>+>+++>>>+++++++>+>+>+++>>+++++++>+>++>>>>>>++++++>>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>+++>++++++>+>++>++>++>++++>++++>++++>++++>++++>++++>++++>++++>+++>+++>+++>+++++++>>>++++++>+>+>++++++>++>+>+>++>+++++++>+++>>>+++++++>+++>+>++>>>>>>>>>+++>>>+++++++>+>++>+>+>+>+>+>++++++>+>+>+>++>>>>+++++++>+>+>+>++>++++++>+>++>>+++>+++++++>+++>>>>++>+>+>++++++>+>+++>>+++++++>+>++>>>>++++++>>++++++>+>+>+>++>>>>+++++++>+>+>+>+++>+++>++++++>+>++>++>++>++++>++++>++++>++++>++++>++++>++++>++++>+++>+++>+++>+++++++>>>++++++>+>+>++++++>++>+>+>++>+++++++>+++>>>+++++++>+++>+>++>>>>>>>>>+++>>>+++++++

>-->>--[-<+]->[++[--->+++]---<++[-<+]->]+++[--->+++]>--[-<+]->---->++[--<>[++[--->+++]---<+++++[----<++++]---->]+++[--->+++]>+[----<++++]>---->++]--<+++++++[--->+++]<--[-<+]->>--[--->+++]--->>--[--<++]-->[++++[-----<+++++]-----<+++++[---->++++]----<+++[--<++]-->]-[-----<+++++]>-[---->++++]>++[------<++++++]------>>+++[---<[++++[-----<+++++]-----<+++++[---->++++]----<+++++++[------<++++++]------>]+++++[-----<+++++]>-[---->++++]>++[------<++++++]>------>>+++]---<<+++++++++++++[-------<+++++++]+[--->+++]---<[+[--<++]--<+++++[---->++++]----<++++[---<+++]---<]>>[+[--<++]-->++++[--->+++]--->]++[--<++]-->>>---[--->+++]--->----->>++++[----<[+++++[------<++++++]------<++++++[----->+++++]----->]++++++[------<++++++]>-[----->+++++]>----->>++++]----<<++++++++++++++[---------<+++++++++]+[---->++++]----<[++[---<+++]---<+++++[---->++++]----<]+++[---<+++]--->>++++++[-<++++++++>]<>-----<<<[->>.<<]+++[[--->+++]---<<[->>>........<<<]+[-[>->]<+]<->++++++++<+++]-->----[---->++++]+++++[-----<+++++]++[--<++]--<+[-[++[--->+++]--->[->+<]<+++>-[--<++]--<]>++<-->+++++[[--->+++]---<<[->>>........<<<]+[-[>->]<+]<->++++++++<+++]-->------[--<++]--<+]->+++++[+[--->+++]---<<[->>>........<<<]++[--[>-->]<++]<->++++++++<++]->-----[--->+++]--->[->+<]<+++>--[-<+]->+++[+[--->+++]---<<[->>>........<<<]++[--[>-->]<++]<->++++++++<++]

The exact number of 0s used is

616143364761046940121393482224894339867345380201767130133313486919095927124457356445367231747521140266173370022946551757495986436536081196868045297628272330390384059772395971191779286883783813697712702083311380720802629542181528279259974270122382291334259076670078283456907144090063837123521728109038972289254725923131778417128787123839239037575809566518515144698909511013229597825122095407702198996899541417882553289474401282217717777845438435506256387112472797473268235689408744655098869728879606757978358505806156421963379547318142883884528468751816610374042589741195416986282360597637951748580316227437951083206547340002950237138353873683827224872420688269051148041914106540181545636126975204020515616888610209347943212212684032994981872040279134760921950441974664462626740824769006477972532358261625821022468550562561067773665916456352101740599621566669636512759138416019741339956533219082231457782020998061560188458949523569043543472825311694153186492127832152368263433627346401816742081184272285138868588737702544161051266511345401776302508848404989044851701234612868569930533447734786659774504348270829815069786996595352931052563253833910670459061338664835111006064026972821593395459376847379338727645638102959876509529598180508190944759740278032543135323831096032264282759700516599819159593380726609694016158768372040897232130064627016970719454234890810133557942103242082428193652525717784679766009840567745646644331050845934041815088097332504352438215802005681361724732417128846494405432135929762912067831306775322080038483165731774473085357566563624402414177907348890170209026776293825006497117681077216606902562225184543780956129658804093641090955334441702108200564658744439989789201224157261892503165643308457788492416371138829568712401818445624554600923862455172225972137155277042400428634635794267865563766239731245919228046855426376607293646700303578427596008362291239931429658436763436719678326692915408656227680419507941034924280704994802195387552837470839012206296262948274121554534825929221937317579576287409893717258523001476821273741591905466514991100795003027995820718624627560000685829593037893516218245771605918736777569490302646860116831211143429524438818972119953427472167111184521816913965170021208796837058611193110390517567196364486837447552746813630060986477162908564149642028449379763465797559696051374230746360712939114777230926431439196151657705180265020483638629061181115856223950249806419818375856529987900246040227082601855626646444080216637310658434683889414278770982063250184353729183793452944251724697854181617951614799763586644028479802980036647045105801552589931160634006431597294780772117688186110086846079813170103829768160563126247208942693587842950980471492950218296552846456932278774596999132699204842933464261728949352373762279520360130690593476460298502885309846199176184758132580237138986886575217114963071503275472309839043003811612480724199448586309349213643468070828586583244591263370384564485550086863984151080517206405235910197380819828141069270492593578986828345436437174028486982241355518138451897126139232242703752607826960024771549490116659322453183855123857138475614101348080310760135256588738232612996648332732281155595814319181966181574401320500067489163573212418944844484950259082074896272135947770797061836016279282123019467117684670513267319113631747092736545960755034809236690912731932588771491682676453979945982754468716932978590114642741630083944274379070387978397185461190324579966999262505612480431374579002240579057976399577489156724969889391725011201833796208889208642431523656036515892951544697280547449403879151875515288785339517008449261777065296448378328263083714549226346273500515673503831635754141766922846713000935292132391822069931132294405910519960461798776924488932623464859144582786720457864275598371518594949910770504649195142874620028228890448589489597208338562687621880437805894822197524541279873734273522403771848708628352939445662430217734644866430785751657273790572085485900108956813143322699032604055731135389248624818347278303261582515845621280853277496120155330289546717304073439125810011869192307295393119864362022104242206053603655047887527558361040028989920694801323274066616457054148538214643602629113440692125709885109559566032777838457552957583786148605526507117591555800832794105245862353696525934364943795116979478987279494334241959368528163214344004159915398916504737171079910682142420502023

poiu45

Posted 2011-01-28T00:34:05.293

Reputation: 21

Welcome to the site! Unary is more often called Lenguage here, but all the same. – Post Rock Garf Hunter – 2020-01-28T03:04:18.630

Lenguage and Unary have different encodings (+- and >< are swapped, no extra leading 1 in Lenguage), so they're not quite the same – Jo King – 2020-01-28T03:06:45.750

2

Haskell, 93 68 characters

s="\nmain=putStrLn$\"s=\"++show s++s"
main=putStrLn$"s="++show s++s

hammar

Posted 2011-01-28T00:34:05.293

Reputation: 4 011

2

Java (229 Characters)

class Main{public static void main(String[]args){char q='"';String s="class Main{public static void main(String[]args){char q='%c';String s=%c%s%c;System.out.print(s.format(s,q,q,s,q));}}";System.out.print(s.format(s,q,q,s,q));}}

Steve P

Posted 2011-01-28T00:34:05.293

Reputation: 131

@Justin Technically, 12 bytes saving. – driima – 2016-11-01T08:59:11.697

4You can shorten it by naming your class a one character name (such as q for quine). Also, there is no need for main(String[]args), just do something like main(String[]a) (total savings: 6 chars) – Justin – 2013-12-11T23:51:48.510

2

Node.js REPL (22)

console.log(RegExp.$1)

nyuszika7h

Posted 2011-01-28T00:34:05.293

Reputation: 1 624

You need to specify the Node version this works in, because running in 7.5.0, this prints a single newline. – Patrick Roberts – 2017-07-16T05:21:32.837

...this abuses the fact that (I guess) the Node REPL internally executes a regex on the received line? I want to upvote because of the cleverness, but on the other hand I don't want to since it relies on extracting its own source code as a string... – FireFly – 2014-08-22T15:38:36.947

2

MATLAB, 95 characters

There might be shorter ones, but I'm happy that it works at all.

function d=g();d='gvodujpo!e>h)*<e>(<e>\e)2;29*.2-e-e)29;foe*.2^<';d=[d(1:18)-1,d,d(18:end)-1];

Cleaner approach, exact same length:

function d=g();d='function d=g();d=[d(1:17),39,d,39,d(15:end)];';d=[d(1:17),39,d,39,d(15:end)];

knedlsepp

Posted 2011-01-28T00:34:05.293

Reputation: 266

2

Mathcad, 94 characters

f:(c{"f:(c{"")]concat(substr(c,0,6),c,substr(c,6,41))")]concat(substr(c,0,6),c,substr(c,6,41))

Watch out for quotation marks autocompletion in the editor!

This should create a parameterless function f which returns its own code.

This quine makes use of (another) weird feature of Mathcad: you can put as much quotation marks inside a string as you like. No idea how they handle it...

Mints97

Posted 2011-01-28T00:34:05.293

Reputation: 561

2

Bash, 67/51 chars

f () 
{ 
    printf "%s\n${!1} $1" "$(local -f ${!1})"
}
f FUNCNAME

And 51 chars:

trap -- 'printf "%s\n:" "$(trap -p DEBUG)"' DEBUG
:

ormaaj

Posted 2011-01-28T00:34:05.293

Reputation: 153

2

Python 2, 31 bytes

s="print's=%r;exec s'%s";exec s

It's 2 bytes longer than the shortest Python quine on this question, but it's much more useful, since you don't need to write everything twice.

For example, to print a program's own source code in sorted order, we can just do:

s="print''.join(sorted('s=%r;exec s'%s))";exec s

Another example by @feersum can be found here.

Notes

The reason the quine works is because of %r's behaviour. With normal strings, %r puts single quotes around the string, e.g.

>>> print "%r"%"abc"
'abc'

But if you have a single quotes inside the string, it uses double quotes instead:

>>> print "%r"%"'abc'"
"'abc'"

This does, however, mean that the quine has a bit of a problem if you want to use both types of quotes in the string.

Sp3000

Posted 2011-01-28T00:34:05.293

Reputation: 58 729

Python appends a leading newline to the output, so you will have to add a newline at the end of your program (making your program 32 bytes, not 31). – MilkyWay90 – 2019-05-04T17:30:00.297

2

Burlesque - 1 byte

Technically, this is a quine:

1

Technically, this is also a quine:

{1 2 3}

Pretty much any literal is a quine.

This is also a quine which doesn't use a simple literal:

,#Q2 SH ~- ",#Q" \/ .+ sh

The comma is not necessary if you launch burlesque in no-stdin mode.

mroman

Posted 2011-01-28T00:34:05.293

Reputation: 1 382

2

AppleScript, 2 Bytes

1

It's a little cheaty, but it is following the restrictions of a quine. If we don't count the trailing newline, then this solution becomes 1 byte - 1.

Whenever AppleScript has a final executed line of code, it prints the result of the last operation (whatever it is) to the command line.

text

Any class name has the same effect.

Addison Crump

Posted 2011-01-28T00:34:05.293

Reputation: 10 763

2

DUP, 51 bytes

0"0.[34,0[$;$][,1+]#]$!%%!"0.[34,0[$;$][,1+]#]$!%%!

Try it here.

Well, DUP quines are possible, just really, really, long. I'll have to golf some more.

Mama Fun Roll

Posted 2011-01-28T00:34:05.293

Reputation: 7 234

2

reticular, 9 bytes

"'34'coo;

This captures the string '34'coo;, then wraps around. After that, the number 34 is pushed the stack, converted to a character with c, finally being outputted with o. The next o outputs the captured string, and ; terminates the program.

Other quines:

"'34'c~O;
"6@P2*c~O;

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2

Python 2 and 3 - 32 bytes

s='s=%r;print(s%%s)';print(s%s)

From Ray Toal's Quine Page

ceilingcat

Posted 2011-01-28T00:34:05.293

Reputation: 5 503

2

Jelly, 6 bytes

There are two proper and payload capable "built-in" quines of 6-bytes:

“ØV”ṘV - takes no input
“ØV”   - make the string “ØV”
    Ṙ  - print and yield left (prints “ØV”, yields “ØV”)
     V - eval Jelly code (the code ØV yields the string “ṘV”)
       - implicit return of the string “ṘV”, so the final output is “ØV”ṘV

and

“Øv”Ṙv - as above,  except:
         v evals with an input, which in this case is empty; and
         Øv yields “Ṙv”

A payload may be placed directly after the leading open quote in either.

Jonathan Allan

Posted 2011-01-28T00:34:05.293

Reputation: 67 804

2

Straw, 10 bytes (non-competing)

(:%>>):%>>

TuxCrafting

Posted 2011-01-28T00:34:05.293

Reputation: 4 547

2

Y, 2 bytes

Try it here!

Up

This is two commands. U is a capture link, and begins quoting the code, and has a U at the beginning of the result. It wraps around, since there is no matching U, and captures the string Up. Then, p prints it, and we are done.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

2

PowerShell, 41 37 Bytes:

function q{"function q{$function:q};q"};q

filter q{"filter q{$function:q};q"};q

Thanks to TimmyD for saving 4 bytes

Chad Baxter

Posted 2011-01-28T00:34:05.293

Reputation: 248

What interpreter / compiler does this work in? In this interpreter, this submission doesn't work (it outputs function q{End: { "function q{$function:q};q" }};q).

– Loovjo – 2016-10-06T18:00:23.003

@Loovjo Most online PowerShell interpreters use an open-source PoSH that's roughly equivalent to PowerShell v0.5 and lacking many features. The above works fine in an actual install on Windows. – AdmBorkBork – 2016-10-07T13:08:34.603

At least in v4 on Windows 8.1, you can shave a few bytes using filter as follows -- filter q{"filter q{$function:q};q"};q for 37. – AdmBorkBork – 2016-10-07T13:09:27.170

$MyInvocation.MyCommand.ScriptBlock is 2 bytes shorter but almost definitely cheating? – colsw – 2017-02-22T22:38:10.963

2

Clean, 123 102 bytes

module q;import StdEnv;Start=(s,q,s,q);q=inc'!';s="module q;import StdEnv;Start=(s,q,s,q);q=inc'!';s="

Save as q.icl and compile with -b -nt.

Saved 21 bytes thanks to Οurous.

user42682

Posted 2011-01-28T00:34:05.293

Reputation:

This can be improved to 102: module q;import StdEnv;Start=(s,q,s,q);q=inc'!';s="module q;import StdEnv;Start=(s,q,s,q);q=inc'!';s=" – Οurous – 2019-02-13T07:09:16.157

@Οurous nice idea, thanks. – None – 2019-02-13T08:36:12.413

1

Zetaplex, 13 bytes

"Sr34SZOsDrFe

Zetaplex is a variant of gammaplex. In it, commands are pairs of chars and act on an infinite stack.

Rɪᴋᴇʀ

Posted 2011-01-28T00:34:05.293

Reputation: 7 410

1

stacked, 16 bytes

Try it here!

[put ':!' put]:!

[put ':!' put] is a func, which is pushed to the stack. : duplicates it, and ! executes it, which prints the function, then :!.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

memes, 2 bytes non-competing

The 3 is irrelevant, as in, any digit apart from 0 could be used. Non-competing as this language was made far after the challenge.

-3

Any mathematical token followed by a digit without anything infront will get interpreted as 0+x, as an example. Therefore -3 will result in 0-3, which returns -3.

devRicher

Posted 2011-01-28T00:34:05.293

Reputation: 1 609

Note simply 3 works too, but that is too much of an obvious reading-from-the-source. – devRicher – 2016-12-26T22:33:22.587

1

R, 47 bytes

f=function(){cat('f=');print(f);cat('f()')}
f()

Try it online!

Can be extended to contain any set of operations by adding those before the first cat statement.

Printing a function f returns the content of that function starting with function(){. I then added cat statements to handle the rest of the output.

JAD

Posted 2011-01-28T00:34:05.293

Reputation: 2 898

should probably be 53 bytes, as print will add indentation and weird brackets placement.

– Giuseppe – 2018-01-25T15:41:47.740

@Giuseppe hmm, on TIO there also appears to be trailing spaces. If counting those we'd end up at 64 bytes – JAD – 2018-01-25T16:36:38.487

:| too long – ASCII-only – 2018-05-13T10:37:37.883

1

Racket, 90 bytes

((lambda (x) (display (list (~a x) (~v x)))) '(lambda (x) (display (list (~a x) (~v x)))))

Matthew Butterick

Posted 2011-01-28T00:34:05.293

Reputation: 401

You can remove unnecessary spaces to golf bytes. I'm not sure what spaces you can remove (cause I use Clojure), but there's definitely spaces that you can remove. – clismique – 2017-01-23T09:37:54.733

Not in this case, because the input has to match the printed output – Matthew Butterick – 2017-01-23T13:12:57.703

Oh... yeah, whoops. I'm just looking at the spaces and thinking that they can be golfed somehow. Well, TIL. – clismique – 2017-01-23T22:00:51.347

1

Pip, 15 bytes

V Y"`V Y`.RPy"

The code includes a trailing newline. Try it online!

Explanation

  Y"..."  Yank this string into the y variable
V         and evaluate it

which executes this:

`V Y`      A Pattern literal (for our purposes, a string-like object without "")
     .     to which we concatenate
      RPy  repr(y), which wraps y in ""

The result is autoprinted with a trailing newline.

Bonus submission, 18 bytes

The above is the shortest Pip quine that I've found, but unfortunately it doesn't do so well when you try to modify it for other quine challenges. I have found this one to be more payload-friendly:

Y"Y yRsRPy"yRsRPy

Y"Y yRsRPy"        Yank that string into y
           yRsRPy  Take y and replace space with repr(y)

DLosc

Posted 2011-01-28T00:34:05.293

Reputation: 21 213

1

AWK, 72 bytes

BEGIN{s="BEGIN{s=%c%s%c;printf s,34,s,34}";printf s,34,s,34}

In 6 years nobody had written an AWK solution :(


This can be run from command-line as:

awk 'BEGIN{s="BEGIN{s=%c%s%c;printf s,34,s,34}";printf s,34,s,34}'

or placed in a file, FILE and run as:

awk -f FILE

Note: no newline is printed so if storing in a file... the file shouldn't have an EOF in it... maybe? We can add an EOF by adding print statements but that adds 12 bytes. This happens to be my first ever quine. :) It took me a bit to figure out how to get the quotation marks, since I first wanted to use \" but I'd have to escape the \ and then escape that one... ASCII to the rescue :)

Robert Benson

Posted 2011-01-28T00:34:05.293

Reputation: 1 339

After I posted this I was curious if there was an extant AWK quine example. Apparently so at https://www.nyx.net/~gthompso/self_awk.txt. Given that, I believe this might be the shortest possible AWK quine.

– Robert Benson – 2017-02-23T21:07:35.727

1

k, 48 bytes

This is, of course, ignoring the trivial quines, such as () or 1.

{}`0:(`c$34)/{(x;x;())}"{}`0:(`c$34)/{(x;x;())}"

Try it out.

zgrep

Posted 2011-01-28T00:34:05.293

Reputation: 1 291

1

Tcl, 61 chars

set c {set c {$c};puts [subst -noc \$c]};puts [subst -noc $c]

Johannes Kuhn

Posted 2011-01-28T00:34:05.293

Reputation: 7 122

1

Scala, 540 Bytes

object Q {
  def main(a:Array[String]):Unit={
    val d=Seq(
      "object Q {",
      "def main(a:Array[String]):Unit={",
      "val d=Seq(",
      "val c=println(_:String)",
      "val b=(x:Int)=>x.toChar.toString",
      "d take 3 map c",
      "val a=d.zipWithIndex.map(x=>b(34)+x._1+b(34)+(if(x._2==d.size-1)b(9).drop(1)else b(44)))",
      "a.map(c)",
      "c(b(41))",
      "d.drop(3).map(c)",
      "c(b(125))",
      "c(b(125))"
    )
    val c=println(_:String)
    val b=(x:Int)=>x.toChar.toString
    d take 3 map c
    val a=d.zipWithIndex.map(x=>b(34)+x._1+b(34)+(if(x._2==d.size-1)b(9).drop(1)else b(44)))
    a.map(c)
    c(b(41))
    d.drop(3).map(c)
    c(b(125))
    c(b(125))
  }
}

Can probably be improved. I decided to call it quits for now as it is 5 in the morning. I think something that can be changed to make this smaller is to encode the d value in some other way other than a sequence of strings. I haven't thought of a cool way to do it yet, though. This would also add to the obfuscation part of the challenge.

Stefan Aleksić

Posted 2011-01-28T00:34:05.293

Reputation: 119

1

Erlang escript 225 164 140

$ escript quine

main(_)->[A|B]=["main(_)->[A|B]=[","],io:put_chars([10,A,34,A,34,44,34,B,34,B,10,10])."],io:put_chars([10,A,34,A,34,44,34,B,34,B,10,10]).

$

Apparently escript has to have at least three lines.

Hynek -Pichi- Vychodil

Posted 2011-01-28T00:34:05.293

Reputation: 350

1

PowerShell, 24 bytes, 21 characters

.($s={".(`$s={$s})"})

I'm going to attempt to explain this, but be forewarned that I'm terrible at explaining myself.

This code sets $s to the following:

".(`$s={$s})"

This recursively sets the variable $s (the first $s is a plain string, but the second $s is the variable $s) in itself and then the block inside parentheses echoes $s, which at time of execution will be the following:

.($s={".(`$s={$s})"})`

wubs

Posted 2011-01-28T00:34:05.293

Reputation: 363

1

Hack 60 bytes

<?hh printf($p='<?hh printf($p=%c%s%c,39,$p,39);',39,$p,39);

Only language I could think to do it in that I didn't see on the list.

Skidsdev

Posted 2011-01-28T00:34:05.293

Reputation: 9 656

1

Brainfuck, 404 bytes

->++>+++>+>+>+++>>>>>>>>>>>>>>>>>>>>>>+>+>++>+++>++>>+++>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+>>+++>>>>+++>>>+++>+>>>>>>>++>+++>+++>+>>+++>+++>+>+++>+>+++>+>++>+++>>>+>+>+>+>++>+++>+>+>>+++>>>>>>>+>+>>>+>+>++>+++>+++>+>>+++>+++>+>+++>+>++>+++>++>>+>+>++>+++>+>+>>+++>>>+++>+>>>++>+++>+++>+>>+++>>>+++>+>+++>+>>+++>>+++>>+[[>>+[>]+>+[<]<-]>>[>]<+<+++[<]<<+]>>>[>]+++>+[+[<++++++++++++++++>-]<++++++++++.<]

Try it online!

I found this quine here; I didn't write it myself. I'm currently trying to understand how it works exactly to add an explanation.

Luke

Posted 2011-01-28T00:34:05.293

Reputation: 4 675

1

Forth, 105 bytes

S" 2dup 34 83 emit emit space type 34 emit space type" 2dup 34 83 emit emit space type 34 emit space type

Try it online

Explanation:

S" 2dup 34 83 emit emit space type 34 emit space type"      \ push a string
   2dup                                                     \ duplicate string
        34 83 emit emit space                               \ print 'S" '
                              type                          \ print string
                                   34 emit space            \ print '" '
                                                 type       \ print string duplicate

mbomb007

Posted 2011-01-28T00:34:05.293

Reputation: 21 944

1

Standard ML (MLton), 60 bytes

";str(chr 34)^it;print(it^it);";str(chr 34)^it;print(it^it);

Try it online!

I previously thought this kind of quine would only work when interpreted, e.g. by the Moscow ML interpreter. However, MLton happily compiles it to a standalone executable, so I guess it's fine.

How it works

Usually one writes val x = <some expression> ; in a SML interpreter to bind the identifier x to result of the evaluation of <some expression>. If the val x = part is omitted, the result is bound to the implicit result identifier it instead.

The quine consists of three declarations:

";str(chr 34)^it;print(it^it);";

A single string, so it = ";str(chr 34)^it;print(it^it);".

str(chr 34)^it;

chr 34 yields the 34th ASCII-character, which is ". str converts the character into a string and the ^-operator performs string concatenation, thus it = "\";str(chr 34)^it;print(it^it);".

print(it^it);

it^it now yields an escaped string version of the source code which is printed to STDOUT with print.

Laikoni

Posted 2011-01-28T00:34:05.293

Reputation: 23 676

1

dc, 16 bytes

[91Pn6120568P]dx

Try it online!

Nothing fancy, posting for completeness.

Explanation

[91Pn6120568P]dx
 91P              # Print "["
    n             # Print the macro
     6120568P     # Print "]dx" encoded as a number
[            ]dx  # Run macro on its own code

eush77

Posted 2011-01-28T00:34:05.293

Reputation: 1 280

1

80x86 TASM, 561 bytes

MODEL TINY
.CODE
.STARTUP
DB 177
DB 076
DB 186
DB 044
DB 001
DB 172
DB 180
DB 036
DB 179
DB 004
DB 191
DB 080
DB 001
DB 079
DB 136
DB 037
DB 212
DB 010
DB 004
DB 048
DB 134
DB 196
DB 075
DB 117
DB 244
DB 180
DB 009
DB 205
DB 033
DB 178
DB 071
DB 226
DB 228
DB 178
DB 038
DB 205
DB 033
DB 195
DB 013
DB 010
DB 069
DB 078
DB 068
DB 036
DB 077
DB 079
DB 068
DB 069
DB 076
DB 032
DB 084
DB 073
DB 078
DB 089
DB 013
DB 010
DB 046
DB 067
DB 079
DB 068
DB 069
DB 013
DB 010
DB 046
DB 083
DB 084
DB 065
DB 082
DB 084
DB 085
DB 080
DB 013
DB 010
DB 068
DB 066
DB 032
END

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

@Downvoter I can kind of understand the downvotes on all the quines I posted from RosettaCode, but this one, really? – MD XF – 2017-05-25T17:23:44.813

1

shortC, 38 28 bytes

AR_="AR_=%c%s%1$c,34,_",34,_

Try it online!

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

1

Bob, 1221 bytes

c=","; n="\n"; q="\""; s="\\";
v=\[
"c=\",\"; n=\"\\n\"; q=\"\\\"\"; s=\"\\\\\";",
"v=\\[",
"define prtQuote(str) {",
" local j,t,v;",
" stdout.Display(q);",
" for (j=0; j<str.size; j++) {",
"  t = str.Substring(j,1);",
"  if (t==q) { stdout.Display(s); }",
"  if (t==s) { stdout.Display(s); }",
"  stdout.Display(t);",
" }",
" stdout.Display(q);",
"}",
"for(i=0; i<2; i++){ stdout.Display(v[i]); stdout.Display(n); }",
"for(i=0; i<v.size-1; i++){ prtQuote(v[i]); stdout.Display(c); stdout.Display(n); }",
"prtQuote(v[v.size-1]); stdout.Display(n);",
"stdout.Display(v[v.size-1]); stdout.Display(n);",
"for(i=2; i<v.size-1; i++){ stdout.Display(v[i]); stdout.Display(n); }",
"];"
];
define prtQuote(str) {
 local j,t,v;
 stdout.Display(q);
 for (j=0; j<str.size; j++) {
  t = str.Substring(j,1);
  if (t==q) { stdout.Display(s); }
  if (t==s) { stdout.Display(s); }
  stdout.Display(t);
 }
 stdout.Display(q);
}
for(i=0; i<2; i++){ stdout.Display(v[i]); stdout.Display(n); }
for(i=0; i<v.size-1; i++){ prtQuote(v[i]); stdout.Display(c); stdout.Display(n); }
prtQuote(v[v.size-1]); stdout.Display(n);
stdout.Display(v[v.size-1]); stdout.Display(n);
for(i=2; i<v.size-1; i++){ stdout.Display(v[i]); stdout.Display(n); }

source

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

1

COBOL, 18808 bytes

This was posted to the mvsHelp forum in 2004. Spaces necessary.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GRICE.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           SYMBOLIC CHARACTERS FULL-STOP IS 76.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT OUTPUT-FILE ASSIGN TO OUTPUT1.
       DATA DIVISION.
       FILE SECTION.
       FD  OUTPUT-FILE
           RECORDING MODE F
           LABEL RECORDS OMITTED.
       01  OUTPUT-RECORD                     PIC X(80).
       WORKING-STORAGE SECTION.
       01  SUB-X                             PIC S9(4) COMP.
       01  SOURCE-FACSIMILE-AREA.
           02  SOURCE-FACSIMILE-DATA.
               03  FILLER                    PIC X(40) VALUE
               "       IDENTIFICATION DIVISION.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       PROGRAM-ID. GRICE.               ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ENVIRONMENT DIVISION.            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       CONFIGURATION SECTION.           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       SPECIAL-NAMES.                   ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           SYMBOLIC CHARACTERS FULL-STOP".
               03  FILLER                    PIC X(40) VALUE
               " IS 76.                                 ".
               03  FILLER                    PIC X(40) VALUE
               "       INPUT-OUTPUT SECTION.            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       FILE-CONTROL.                    ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           SELECT OUTPUT-FILE ASSIGN TO ".
               03  FILLER                    PIC X(40) VALUE
               "OUTPUT1.                                ".
               03  FILLER                    PIC X(40) VALUE
               "       DATA DIVISION.                   ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       FILE SECTION.                    ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       FD  OUTPUT-FILE                  ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           RECORDING MODE F             ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           LABEL RECORDS OMITTED.       ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       01  OUTPUT-RECORD                ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X(80).                         ".
               03  FILLER                    PIC X(40) VALUE
               "       WORKING-STORAGE SECTION.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       01  SUB-X                        ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC S9(4) COMP.                    ".
               03  FILLER                    PIC X(40) VALUE
               "       01  SOURCE-FACSIMILE-AREA.       ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           02  SOURCE-FACSIMILE-DATA.   ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               03  FILLER               ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X(40) VALUE                    ".
               03  FILLER                    PIC X(40) VALUE
               "           02  SOURCE-FACSIMILE-TABLE RE".
               03  FILLER                    PIC X(40) VALUE
               "DEFINES                                 ".
               03  FILLER                    PIC X(40) VALUE
               "                   SOURCE-FACSIMILE-DATA".
               03  FILLER                    PIC X(40) VALUE
               ".                                       ".
               03  FILLER                    PIC X(40) VALUE
               "               03  SOURCE-FACSIMILE OCCU".
               03  FILLER                    PIC X(40) VALUE
               "RS 68.                                  ".
               03  FILLER                    PIC X(40) VALUE
               "                   04  SOURCE-FACSIMILE-".
               03  FILLER                    PIC X(40) VALUE
               "ONE  PIC X(40).                         ".
               03  FILLER                    PIC X(40) VALUE
               "                   04  SOURCE-FACSIMILE-".
               03  FILLER                    PIC X(40) VALUE
               "TWO  PIC X(40).                         ".
               03  FILLER                    PIC X(40) VALUE
               "       01  FILLER-IMAGE.                ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER                   ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X(15) VALUE SPACES.            ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER                   ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X     VALUE QUOTE.             ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER-DATA              ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X(40).                         ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER                   ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X     VALUE QUOTE.             ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER                   ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X     VALUE FULL-STOP.         ".
               03  FILLER                    PIC X(40) VALUE
               "           02  FILLER                   ".
               03  FILLER                    PIC X(40) VALUE
               "     PIC X(22) VALUE SPACES.            ".
               03  FILLER                    PIC X(40) VALUE
               "       PROCEDURE DIVISION.              ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       MAIN-LINE SECTION.               ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ML-1.                            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           OPEN OUTPUT OUTPUT-FILE.     ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE 1 TO SUB-X.             ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ML-2.                            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE (SUB-X)".
               03  FILLER                    PIC X(40) VALUE
               " TO OUTPUT-RECORD.                      ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           IF  SUB-X < 19               ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               ADD 1 TO SUB-X           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               GO TO ML-2.              ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE 1 TO SUB-X.             ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ML-3.                            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE (20) TO".
               03  FILLER                    PIC X(40) VALUE
               " OUTPUT-RECORD.                         ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE-ONE (SU".
               03  FILLER                    PIC X(40) VALUE
               "B-X) TO FILLER-DATA.                    ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE FILLER-IMAGE TO OUTPUT-R".
               03  FILLER                    PIC X(40) VALUE
               "ECORD.                                  ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE (20) TO".
               03  FILLER                    PIC X(40) VALUE
               " OUTPUT-RECORD.                         ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE-TWO (SU".
               03  FILLER                    PIC X(40) VALUE
               "B-X) TO FILLER-DATA.                    ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE FILLER-IMAGE TO OUTPUT-R".
               03  FILLER                    PIC X(40) VALUE
               "ECORD.                                  ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           IF  SUB-X < 68               ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               ADD 1 TO SUB-X           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               GO TO ML-3.              ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE 21 TO SUB-X.            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ML-4.                            ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           MOVE SOURCE-FACSIMILE (SUB-X)".
               03  FILLER                    PIC X(40) VALUE
               " TO OUTPUT-RECORD.                      ".
               03  FILLER                    PIC X(40) VALUE
               "           WRITE OUTPUT-RECORD.         ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           IF  SUB-X < 68               ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               ADD 1 TO SUB-X           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "               GO TO ML-4.              ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "       ML-99.                           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           CLOSE OUTPUT-FILE.           ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
               03  FILLER                    PIC X(40) VALUE
               "           STOP RUN.                    ".
               03  FILLER                    PIC X(40) VALUE
               "                                        ".
           02  SOURCE-FACSIMILE-TABLE REDEFINES
                   SOURCE-FACSIMILE-DATA.
               03  SOURCE-FACSIMILE OCCURS 68.
                   04  SOURCE-FACSIMILE-ONE  PIC X(40).
                   04  SOURCE-FACSIMILE-TWO  PIC X(40).
       01  FILLER-IMAGE.
           02  FILLER                        PIC X(15) VALUE SPACES.
           02  FILLER                        PIC X     VALUE QUOTE.
           02  FILLER-DATA                   PIC X(40).
           02  FILLER                        PIC X     VALUE QUOTE.
           02  FILLER                        PIC X     VALUE FULL-STOP.
           02  FILLER                        PIC X(22) VALUE SPACES.
       PROCEDURE DIVISION.
       MAIN-LINE SECTION.
       ML-1.
           OPEN OUTPUT OUTPUT-FILE.
           MOVE 1 TO SUB-X.
       ML-2.
           MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           IF  SUB-X < 19
               ADD 1 TO SUB-X
               GO TO ML-2.
           MOVE 1 TO SUB-X.
       ML-3.
           MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           MOVE SOURCE-FACSIMILE-ONE (SUB-X) TO FILLER-DATA.
           MOVE FILLER-IMAGE TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           MOVE SOURCE-FACSIMILE-TWO (SUB-X) TO FILLER-DATA.
           MOVE FILLER-IMAGE TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           IF  SUB-X < 68
               ADD 1 TO SUB-X
               GO TO ML-3.
           MOVE 21 TO SUB-X.
       ML-4.
           MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD.
           WRITE OUTPUT-RECORD.
           IF  SUB-X < 68
               ADD 1 TO SUB-X
               GO TO ML-4.
       ML-99.
           CLOSE OUTPUT-FILE.
           STOP RUN.

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

1

Vim, 27 bytes

ii^V^V^V^[BDuplxbbpp^[BDuplxbbpp

^V being CTRL+V and ^[ being ESC.

The other one is beating mine, but it took a while and I didn't think it was possible.

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

1

Bash, 54 52 bytes

-2 thanks to Ørjan Johansen

a=\' b='a=\\$a b=$a$b$a\;eval echo \$b';eval echo $b

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

The spaces after the semicolons seem unnecessary. – Ørjan Johansen – 2017-05-27T02:06:23.327

@ØrjanJohansen Oh, I completely forgot to golf that part! Thanks :D – MD XF – 2017-05-27T02:27:09.297

You forgot to include the new length. – Ørjan Johansen – 2017-05-27T02:39:59.707

@ØrjanJohansen Is there any limit to how helpful you can be :P – MD XF – 2017-05-27T02:40:45.533

1

Add++, 14 bytes

L,"L,%rd%%"d%

Try it online!

Takes advantage of Python string formatting with the % command.

caird coinheringaahing

Posted 2011-01-28T00:34:05.293

Reputation: 13 702

1

><>, 42 Bytes

'r3d*>l?\ao"/o \     "ooooooooo;
     \ o/

Try it online

Sasha

Posted 2011-01-28T00:34:05.293

Reputation: 431

1

RProgN 2, 3 bytes


«Ø

Try it online!

This code does nothing with the first line, then, pushes the function «Ø. As « is unmatched, it falls through and executes the contents. Ø then pushes an empty string. The implicit printing behaviour first prints the empty string, then the function, giving our source code.

4 bytes

«•. 

(With a leading space)

Try it online!

This uses the fall through behavoir of the last quine, but ensures "quine" behavoir a different way. pushes a space, . concatenates it, which gives our code.

6 bytes

{`{.}{

Try it online!

This uses a different fallthrough behavoir. {`{.} pushes a funciton, then {, with an unmatched }, fails and moves the IP back to index 1, which skips the function definition, and runs its contents instead. (backtick){ pushes { as a string, then . appends it to the function, stringifying it. } then terminates the program, and the string is implicitely output.

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

1

OML, 20 bytes

"lK(34Tos)"lK(34Tos)

Try it online!

This was an interesting process. I initially started off with the classic data-decoder method of quining. That is, one devotes one section of the program to encoding the decoder, and another section to generate the data representation and decode the data. This came out to look like this (51 bytes):

'\'l'K'l'2'/'['('''''o'o')']'('o')\lKl2/[(''oo)](o)

Where the data section looks like:

'\'l'K'l'2'/'['('''''o'o')']'('o')

which pushes each character after a '. The decoder looks like this:

\lKl2/[(''oo)](o)
\                  reverse stack
 lK                duplicate stack
   l2/[            copy the duplication into a new stack
       (    )      while there are characters on this stack:
        ''o          output a single quote
           o         and the character
             ]     return to the original stack
              (o)  output all characters on this stack

This can be improved slightly by replacing (o) with ls (48 bytes):

'\'l'K'l'2'/'['('''''o'o')']'l's\lKl2/[(''oo)]ls

However, OML also has a length-encoded string construct. Let's say the string is "xyz". This is effectively 'x'y'z3, since there are three characters in the string. We can use s to print this string, but we still need to generate the quote characters. With all this in mind, I was able to devise the following approach (26 bytes):

"lK34Tos34Tos"lK34Tos34Tos

Simply put, this puts the "string" "lK34Tos34Tos" to the stack, then performs the following actions:

lK34Tos34Tos
lk            duplicate the stack (in this case, the string)
  34To        output a quotation mark "
      s       output the string
       34To   output another quotation mark "
           s  output the string again

We obtain our final version by noting that the structure 34Tos is repeated twice. We can use a while loop to produce the current answer.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

Funky, 21 bytes

f=@write`f=[f]f()`f()

Try it online!

or, if Functions are allowed...

Funky, 9 bytes

f=@'f='+f

The second of these defines a function f which returns the string f=@'f='+f, the first however is a full program.

Try it online!

ATaco

Posted 2011-01-28T00:34:05.293

Reputation: 7 898

1

Locksmith, 201 bytes

070405000400080701090704000102010702070000080006030109000107020001020106070707040507040001020107020700000800060301090001070200010201067450408719740121727008063190172012167774574012172700806319017201216

Try it online!

Formatted:

0704050004000807010907040001020107020700000800060301090001070200010
2010607070704050704000102010702070000080006030109000107020001020106
7450408719740121727008063190172012167774574012172700806319017201216

This consists of two parts: the data section and the decoder. The data section is simply each byte of the encoder prefixed with a 0 (which is the command to push that number). The decoder is:

74              // push stack length
5               // that many times:
   0408719      // output a 0
   74012172     // bring bottom of stack to the top
   700806319    // output this without popping
   0172         // swap top two (brings length to top)
   0121         // decrement
6               // close loop    

7774            // pop counter, push length again
5
   74012172     // bring bottom to top
   700806319    // output
   0172         // bring length to top
   0121         // decrement
6               // close loop

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

Swift 4, 120 bytes

import Foundation;let q="import Foundation;let q=%c%@%c;print(String(format:q,34,q,34))";print(String(format:q,34,q,34))

Try See it online!

Since this code imports Foundation, and the Swift corelibs can be a little quirky in non-macOS environments, you might not be able to run it (it doesn't work in TIO, or IBM's Swift Sandbox). If, however, you have a macOS environment, then you should be just fine.

osuka_

Posted 2011-01-28T00:34:05.293

Reputation: 391

1

Foo, 136 111 96 bytes

I'm surprised to see that there's no Foo quine here yet!

>&41>&60>&99>&36>&40>&60>&41>&62>&105>&36>&34>&38>&62>&34>&40>&62>&41>&60>&40(<)>(">&"$i>)<($c<)

Try it online!

Explanation

This is pretty simple as far as quines go. There are two sections: the data and the decoder. The data is encoded on the array, and is decoded as such:

(<)>(">&"$i>)<($c<)

Which basically iterates once over the tape, outputting >& and the integer value of the cell, then iterating once again over the tape, outputting each character. The tape, then, is just the character codes of this decoder.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

Javascript REPL, 21 bytes

(_=$=>`(_=${_})()`)()

Carles Capellas

Posted 2011-01-28T00:34:05.293

Reputation: 11

1

Yabasic, 103 bytes

An anonymous Yabasic quine

c$=Chr$(34):q$="c$=Chr$(34):q$=:?Left$(q$,15)+c$+q$+c$+Mid$(q$,16)":?Left$(q$,15)+c$+q$+c$+Mid$(q$,16)

Includes a trailing newline

Try it online!

Taylor Scott

Posted 2011-01-28T00:34:05.293

Reputation: 6 709

1

Excel, 17 Bytes

In cell A1...

=FunctionText(A1)

I discovered this yesterday by accident. Feels a bit cheaty somehow though. I appreciate this answer much more, but this does seem to be a quine :D

seadoggie01

Posted 2011-01-28T00:34:05.293

Reputation: 181

1

Pascal (FPC), 103 bytes

const s=#39'const s=#39;begin write(s[2..12],s,s[10..50])end.'#39;begin write(s[2..12],s,s[10..50])end.

Try it online!

s is the string that the output is generated from. In Pascal, subtrings can be easily extracted with [from..to] syntax. #39 is replacement for ' using its ASCII codepoint. As seen in this program, sequences of character codepoints can be glued together with the rest of the string delimited with 's at any time. s consists of characters before and after 's concatenated together. #39 occurs immediately before first ' and after second ' so it can be put in s only once and used in both substrings in the output.

 
The version that may be more suitable in modified, quine-like programs is at 106 bytes:

const s='const s=;begin write(s[1..8],#39,s,#39,s[9..52])end.';begin write(s[1..8],#39,s,#39,s[9..52])end.

Try it online!

AlexRacer

Posted 2011-01-28T00:34:05.293

Reputation: 979

1

!@#$%^&*()_+, 76 bytes

40Kjiiiiiiiiiiij,306j,6641,iK31,i,6j,,!!_+!^!&(@^!&)++!_+%(!_^^^^^^^^^^^_@%)

Try it online!

The code can be decomposed into two sections: the data and the decoder. The data is this:

40Kjiiiiiiiiiiij,306j,6641,iK31,i,6j,,

Each character pushes itself, and corresponds to a command (shifted up by 11).

The decoder is this:

!!_+!^!&(@^!&)++!_+%(!_^^^^^^^^^^^_@%)

This can also be divided into two parts, one which prints the data raw, and one which decodes the data. This part prints the initial data segment:

!!_+!^!&(@^!&)++!_+%
!!_+                     push 0 (duplicate twice then subtract)
                         this is our delineator
    !^                   push 1 (duplicate and increment)
                         this is our pointer
      !&                 push the entry at that index in the stack
        (    )           until the dilineator is found:
         @               output the stack entry
          ^              increment pointer
           !&            refresh entry at index
              ++!_+      pop top two (add twice, duplicate, subtract)
                   %     push 0 underneath stack

Then the decoder:

(!_^^^^^^^^^^^_@%)
(               %)    For each character:
 !_           _           subtract
   ^^^^^^^^^^^            11
               @          and output it

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

Muriel, 36 bytes

A:"\";.\"A:\\\"\"+|A+A";."A:\""+|A+A

Try it online!

Since Muriel isn't on TIO (yet!), I've included the interpreter in the link. Thanks Dennis!

Quines are the base component of any complex Muriel program, since they're a requirement for any sort of loop.

Explanation:

A:        Assign to A
  "       ...         "; An escaped version of ";."A:\""+|A+A
                        .          Print
                         "A:\""          A:"
                               +|A       Escaped version of A
                                  +A     Then A itself

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

1

Aubergine, 16 bytes

-a1+a1=oA:bA=iB

Try it online!

The program has a trailing null byte. Works similarly to my hello world.

ASCII-only

Posted 2011-01-28T00:34:05.293

Reputation: 4 687

1

Brachylog v2, 12 bytes

"~k;?w₁";?w₁

Try it online!

Full program. Essentially a translation of Fatalize's (non-builtin) Brachylog v1 answer, although it also uses different SWI-Prolog formatting sequences, or rather, a single different one, which saves about 20 bytes (both [34:s, both :34]s, and both ~cs). It seems to have existed back in 2016, but it was probably bugged or something. The last two bytes saved come from using the implicit input, which Brachylog being Brachylog is useful even when the program receives no input, because it's a variable (so instead of explicitly unifying the string with S, we just let it be implicitly unified with ?).

          w     Print
"~k;?w₁"        "~k;?w₁"
                which is the input
           ₁    formatted with
        ;?      the input.
 ~k             (so that the ~k is replaced with the input's canonical representation, i.e. in quotes)

We don't actually need to use implicit input--"~kgjw₁"gjw₁ works just as well (and might even translate back to v1)--but doing so regardless manages to both more closely mirror the structure of the original and feel cleverer.

Unrelated String

Posted 2011-01-28T00:34:05.293

Reputation: 5 300

1

Java, 515 bytes

In order to make this quine, I made strings representing every part of the code that needed to be printed. Then, I created and printed a string representing the code by adding the strings together.

This is my first time playing code golf, let me know what you think of my quine!

interface a{static void main(String[]a){String ce="interface a{static void main(String[]a){String ",e="=",c="\",",q="\"",cq="\\",ec=";System.out.print(ce+cc+ee+e+q+ce+c+ee+e+q+e+c+cc+e+q+cq+c+c+qq+e+q+cq+q+c+cc+qq+e+q+cq+cq+c+ee+cc+e+q+ec+c+ee+qq+e+q+eq+c+ee+ee+e+q+ee+c+cc+cc+e+q+cc+c+qq+qq+e+q+qq+q+ec+eq",eq=");}}",ee="e",cc="c",qq="q";System.out.print(ce+cc+ee+e+q+ce+c+ee+e+q+e+c+cc+e+q+cq+c+c+qq+e+q+cq+q+c+cc+qq+e+q+cq+cq+c+ee+cc+e+q+ec+c+ee+qq+e+q+eq+c+ee+ee+e+q+ee+c+cc+cc+e+q+cc+c+qq+qq+e+q+qq+q+ec+eq);}}

in readable form:

interface a
{
    static void main(String[] a)
    {
        String ce = "interface a{static void main(String[]a){String ",
            e = "=",
            c = "\",",
            q = "\"",
            cq = "\\",
            ec = ";System.out.print(ce+cc+ee+e+q+ce+c+ee+e+q+e+c+cc+e+q+cq+c+c+qq+e+q+cq+q+c+cc+qq+e+q+cq+cq+c+ee+cc+e+q+ec+c+ee+qq+e+q+eq+c+ee+ee+e+q+ee+c+cc+cc+e+q+cc+c+qq+qq+e+q+qq+q+ec+eq",
            eq = ");}}",
            ee = "e",
            cc = "c",
            qq = "q";
        System.out.print(ce+cc+ee+e+q+ce+c+ee+e+q+e+c+cc+e+q+cq+c+c+qq+e+q+cq+q+c+cc+qq+e+q+cq+cq+c+ee+cc+e+q+ec+c+ee+qq+e+q+eq+c+ee+ee+e+q+ee+c+cc+cc+e+q+cc+c+qq+qq+e+q+qq+q+ec+eq);
    }
}

Ethan Gallagher

Posted 2011-01-28T00:34:05.293

Reputation: 21

If you want to try shortening this further, have a look into using the printf function – Jo King – 2019-06-28T06:41:25.907

I tried that, but I found print easier. I guess I'll try again. – Ethan Gallagher – 2019-07-01T02:22:01.563

1

Javascript (REPL), 23 22 21 bytes

someone else posted this first

(_=x=>`(_=${_})()`)()

paste into chrome console or equivalent to test

JavaScript (V8), 49 48 47 bytes

@NieDzejkob saved 1 byte on both versions

console.log((_=x=>`console.log((_=${_})())`)())

Try it online!

Kenneth Taylor

Posted 2011-01-28T00:34:05.293

Reputation: 183

1

Save a byte like this: Try it online!

– NieDzejkob – 2019-08-01T22:50:42.253

Would print((_=x=>`print((_=${_})())`)()) count too? JavaScript (V8) 35 bytes

– pixma140 – 2019-08-20T08:30:55.097

1

C, 353 bytes

char q[]={125,59,109,97,105,110,40,41,123,112,114,105,110,116,102,40,34,99,104,97,114,32,113,91,93,61,123,34,41,59,99,104,97,114,42,112,61,113,59,119,104,105,108,101,40,42,112,41,112,114,105,110,116,102,40,34,37,100,44,34,44,42,112,43,43,41,59,112,117,116,115,40,113,41,59,125,};main(){printf("char q[]={");char*p=q;while(*p)printf("%d,",*p++);puts(q);}

T. Salim

Posted 2011-01-28T00:34:05.293

Reputation: 575

1

With some golfing, including changing it from hexadecimal to decimal, this can be 354 bytes

– Jo King – 2019-08-02T02:04:03.797

Wait Jo, I tried your solution in the gcc compiler and it unfortunately gave an error for the second quine program compiled from the first. – T. Salim – 2019-08-02T02:35:03.710

1The link itself is a gcc compiler and it works fine. Are you sure they aren't just warnings? – Jo King – 2019-08-02T02:51:22.823

Its not just warnings, Jo. There is unfortunately error called "initializer element is not constant" due to what gcc perceives as a formatting error. Yes, in my compiler, they were just warnings at the first compilation stage. But you see, I actually tested each of the offspring quine programs in succession, and I unfortunately ran into the following errors according to gcc for the second offspring quine program:ken_quine2.c:1:274: ken_quine2.c:1:274: error: initializer element is not constant – T. Salim – 2019-08-02T02:52:24.297

1If only the output is erroring, then what is the difference between the two programs? What version of gcc are you using? – Jo King – 2019-08-02T03:15:03.780

I am using gcc 7.4.0 in CYGWIN. The difference is that the second generation quine program fails to compile and print. – T. Salim – 2019-08-02T03:19:43.953

1... What is the difference between the code of the two programs, not their behaviour. I already know that the second one fails. The version TIO uses is 8.3, and that works fine. – Jo King – 2019-08-02T03:32:27.790

Then this clears why we were disagreeing with each other. I simply was using an older compiler. So I guess I should use the most up to date compiler for code golf then. – T. Salim – 2019-08-02T03:34:44.603

For curiosity's sake, what was the older compiler outputting? – Jo King – 2019-08-02T03:36:09.070

The warnings and errors were so huge that there is not enough space to paste what the compiler said here. It said the following error messages:ken_quine2.c:1:274: error: initializer element is not constant ken_quine2.c:1:274: note: (near initialization for ‘q[75]’) ken_quine2.c:1:280: error: expected ‘}’ before ‘{’ token – T. Salim – 2019-08-02T03:44:19.597

1*I don't care about the output of the second generation quine. I would like to know the output of the first program, the one that didn't fail and produced something that did. I don't want to know about the errors that you have commented about several times already. I would like to know the difference between the program I have given you and its output. You can put the program in an online compiler like I have and link it in a comment below.* – Jo King – 2019-08-02T03:49:44.857

Here – T. Salim – 2019-08-02T03:58:56.460

1That appears to be no different to the first program. Why would it not error the first time, but error the second time? – Jo King – 2019-08-02T04:00:38.900

Yes, there is no difference when using the TIO compiler. Jo, the real reason why this argument started was because we were using different compilers in the first place. That started the confusion. I think we should end the discussion here. – T. Salim – 2019-08-02T04:02:43.903

1I just want to know why the second program would error, but the original doesn't, as you said it unfortunately gave an error for the second quine program compiled from the first. I would understand the original program throwing an error, but I see no reason for it to work, but cause the second generation one to fail. – Jo King – 2019-08-02T04:04:53.817

Good question, I honestly do not really get why gcc 7.4.0 was acting like this either. Everything honestly looked syntatically correct and indistinguishable even in the error messages. – T. Salim – 2019-08-02T04:09:03.453

Can you please edit in the corrections to the program/score? Otherwise it may get deleted as not a valid answer. You can also use my improved version or try improving it yourself, since I'm not that familiar with C. – Jo King – 2019-08-03T04:03:39.750

Sure. I'll add in the edited version. – T. Salim – 2019-08-03T04:11:50.513

1

C (gcc), 85 bytes

#define q(k)main(){puts(#k"\nq("#k")");}
q(#define q(k)main(){puts(#k"\nq("#k")");})

Try it online!

The q() macro expands into a program that prints out its argument on the first line, and prints out the argument called by q() itself in the second line. So:

#define q(k)main(){puts(#k"\nq("#k")");}
q(foo)

would expand into:

main(){puts("foo""\nq(""foo"")");}

and after string literal concatenation, becomes:

main(){puts("foo\nq(foo)");}

And executing and running the program would produce:

foo
q(foo)

Replacing foo with the macro definition itself results in the quine.

jxh

Posted 2011-01-28T00:34:05.293

Reputation: 331

1

Wren, 287 bytes

var a="[118,97,114,32,97,61,34].each{|m|System.write(String.fromCodePoint(m))}
System.write(a+String.fromCodePoint(34)+String.fromCodePoint(10)+a)"
[118,97,114,32,97,61,34].each{|m|System.write(String.fromCodePoint(m))}
System.write(a+String.fromCodePoint(34)+String.fromCodePoint(10)+a)

Try it online!

Explanation

var a=                                                                         // Define the variable a
      "[118,97,114,32,97,61,34].each{|m|System.write(String.fromCodePoint(m))}
System.write(a+String.fromCodePoint(34)+String.fromCodePoint(10)+a)"           // As the string that processes the variable

                                                                               // A literal newline is inserted and can be decoded literally.

[118,97,114,32,97,61,34].each{|m|System.write(String.fromCodePoint(m))}        // Output the string "var a=" to the console
System.write(                                                                  // Output without a newline:
             a                                                                 // The string a
              +String.fromCodePoint(34)                                        // Plus a quote
                                       +String.fromCodePoint(10)               // Plus a newline
                                                                +a)            // Plus the string again
```

user85052

Posted 2011-01-28T00:34:05.293

Reputation:

Why doesn't fromByte work in place of fromCodePoint? – Jo King – 2019-10-29T23:28:10.103

I have absolutely no idea. – None – 2019-10-30T03:57:07.053

1

Keg, 8 6 4 bytes

`④`④

Try it online!

Answer History

8 bytes

`:.,`:.,

Try it online!

Why did it take me so long to figure out how to write a quine in Keg? I really should have picked up on this sooner.

Basically, it pushes the string :.,, duplicates it, prints the string repr'd and then prints it nicely.

Lyxal

Posted 2011-01-28T00:34:05.293

Reputation: 5 253

1

Symbolic Raku, 36 bytes

$_={$_~"<$_>)"}(<$_={$_~"<$_>)"}(>)

Try it online!

Explanation:

$_=                                   # Set the output to
   {          }(                  )   # The result of the code block
                <                >    # With this string:
                 $_={$_~"<$_>)"}(        # The first half of the program
    $_~                               # Concatenate this string with
       "<$_>)"                        # The quoted string, and the extra bracket

Jo King

Posted 2011-01-28T00:34:05.293

Reputation: 38 234

1

tq, 8 bytes

New high-level language! (Technically inspired by Jo King's Symbolic Raku quine.)

etq'etq'

Explanation

   'etq' # Define the second item of the list
         # As a string
  q      # Surround the string with quotes
 t       # For the first item of the list,
         # Access the last (tail) item in the list,
e        # and evaluate the accessed value.

# The list becomes etq, 'etq' (comma is for readability)
# , which then becomes foreach-printed without any separator.
```

user85052

Posted 2011-01-28T00:34:05.293

Reputation:

1

Go - 583

Just because d;

package main
import "fmt"
func main(){
    a := string(byte(34))
    b := []string{
        "package main",
        "import fmt",
        "func main(){",
        "   a := string(byte(34))",
        "   b := []string{",
        "       ",
        "   }",
        "   for i:=0;i<5;i++{if i != 1{fmt.Println(b[i])}else{fmt.Println(b[i][:7]+a+b[i][7:]+a)}}",
        "   for _,v:=range b{fmt.Println(b[6]+a+v+a+string(','))}",
        "   for i:=7;i<9;i++{fmt.Println(b[i])}",
        "}",
        }
    for i:=0;i<5;i++{if i != 1{fmt.Println(b[i])}else{fmt.Println(b[i][:7]+a+b[i][7:]+a)}}
    for _,v:=range b{fmt.Println(b[5]+a+v+a+string(','))}
    for i:=7;i<11;i++{fmt.Println(b[i])}
}

globby

Posted 2011-01-28T00:34:05.293

Reputation: 1 132

this is awesome. – cat – 2015-12-07T14:50:35.037

1

Groovy:

`s='s=\\\';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*`2

Edit

Works in GroovyConsole

Ant's

Posted 2011-01-28T00:34:05.293

Reputation: 281

1

D, 85 bytes

enum c=q{import std.stdio;void main(){write("enum c=q{"~c~"};mixin(c);");}};mixin(c);

ratchet freak

Posted 2011-01-28T00:34:05.293

Reputation: 1 334

1

C, 125 84 chars

main(){char*p="main(){char*p=%c%s%c,c='%c',s[256];sprintf(s,p,c,p,c,c);puts(s);}",c='"',s[256];sprintf(s,p,c,p,c,c);puts(s);}

It turns out that my idea was implemented much better:

main(){char*p="main(){char*p=%c%s%c;printf(p,34,p,34,10);}%c";printf(p,34,p,34,10);}

Alexander Bakulin

Posted 2011-01-28T00:34:05.293

Reputation: 389

1You could shave 9 chars off the shorter version by leaving out the trailing newline. – Ilmari Karonen – 2012-02-03T18:55:46.777

1

Ada, 274 258 257 Characters

with Text_IO;use Text_IO;procedure Q is M:Character:='"';T:String:="with Text_IO;use Text_IO;procedure Q is M:Character:=';T:String:=;begin Put_Line(T(1..54)&M&T(54..65)&M&T&M&T(66..126));end Q;";begin Put_Line(T(1..54)&M&T(54..65)&M&T&M&T(66..126));end Q;

pretty printed:

with Text_IO;
use Text_IO;
procedure Quine is
   M : Character := '"';
   T : String := "with Text_IO;use Text_IO;" &
     "procedure Q is M:Character:=';T:String:=;" &
     "begin Put_Line(T(1..54)&M&T(54..65)&M&T&M&T(66..126));end Q;";
begin
   Put_Line(T(1..54)&M&T(54..65)&M&T&M&T(66..126));
end Quine;

this program actually produces the short version (output can be redirected to q.adb).

oenone

Posted 2011-01-28T00:34:05.293

Reputation: 161

1

Cobra - 143

class P
    def main
        s='class P{2}   def main{2}     s={1}{0}{1}{2}      Console.write(s,s,39to char,10to char)'
        Console.write(s,s,39to char,10to char)

Οurous

Posted 2011-01-28T00:34:05.293

Reputation: 7 916

1

Julia, 101 characters

s="s=%c%s%c;@printf %c%s%c 34 s 34 34 s 34";@printf "s=%c%s%c;@printf %c%s%c 34 s 34" 34 s 34 34 s 34

It's the usual format string technique, but unfortunately you can't get the format specification string from a variable in Julia, so I have to include it twice in the code, which blows everything up.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

1

Lua, 76 characters

s="s=%c%s%c;print(string.format(s,34,s,34))";print(string.format(s,34,s,34))

Another one with the usual format string technique.

Martin Ender

Posted 2011-01-28T00:34:05.293

Reputation: 184 808

1

Common Lisp - 73 35

Thanks to reader variables written #n= and #n#, with n an integer, Lisp code can be self-referential. Also, the printing functions can emit such reader variables when told to handle circular structures. The WRITE function accepts a :circle parameter for that purpose. It also returns the value being printed, which means that we have to globally set *PRINT-CIRCLE* to T (the initial, standard value is NIL), otherwise the REPL would report a stack-overflow exception when printing that value. Initializing the variable takes a lot of bytes and so the shorter solution is to return another value:

#1=(PROGN (WRITE '#1# :CIRCLE T) T)

coredump

Posted 2011-01-28T00:34:05.293

Reputation: 6 292

1

F♯# - 349 Characters

let s="\\\"\nnlet s=let z a b=s.Substring(a,b)System.Console.WriteLine()z 4 6+z 1 1+z 0 1+z 0 1+z 0 1+z 1 1+z 0 1+z 3 1+z 3 1+z 4 169+z 1 1+z 2 1+z 10 26+z 2 1+z 36 25+z 62 111+z 61 1" 
let z a b=s.Substring(a,b)
System.Console.WriteLine(z 4 6+z 1 1+z 0 1+z 0 1+z 0 1+z 1 1+z 0 1+z 3 1+z 3 1+z 4 169+z 1 1+z 2 1+z 10 26+z 2 1+z 36 25+z 62 111+z 61 1)

My first attempt at a quine - probably an easier (or shorter) way to do it, but not a bad first attempt I don't think

lochok

Posted 2011-01-28T00:34:05.293

Reputation: 3 139

1

Minkolang 0.9, 10 bytes

This language was made after this challenge, but was not made for it.

"66*2-(O).

Like other 2D languages, the " makes everything between it and the next " a string. 66*2- adds the not-included " and (O). prints everything out and stops.

El'endia Starman

Posted 2011-01-28T00:34:05.293

Reputation: 14 504

1

Scala, 84 bytes

val d="""
print("val d=\"\"\""+d+"\"\"\""+d)
"""
print("val d=\"\"\""+d+"\"\"\""+d)

Kinda straightforward, but putting it out there for completion.

triggerNZ

Posted 2011-01-28T00:34:05.293

Reputation: 251

1

Seriously, 2 bytes

1

Pushes the number 1, implicit print with trailing newline. Since this is fairly trivial, here is the smallest non-trivial quine which can contain arbitrary characters (12 bytes):

`è";ƒ"@+`;ƒ

quintopia

Posted 2011-01-28T00:34:05.293

Reputation: 3 899

1

Python 3 - 58 Characters

Since there is a Python 2 version, I suppose this is acceptable:

x='x={};print(x.format(repr(x)))';print(x.format(repr(x)))

padawan

Posted 2011-01-28T00:34:05.293

Reputation: 294

1

Java, 190 Characters

class I{public static void main(String[]a){String s="class I{public static void main(String[]a){String s=%c%s%1$c;System.out.print(s.format(s,34,s));}}";System.out.print(s.format(s,34,s));}}

Minimal

Posted 2011-01-28T00:34:05.293

Reputation: 131

Since ye olde Java SE 8, you can put static methods (such as main) in interfaces - no public. Also print and format methods can be collapsed into printf. – Tom Hawtin - tackline – 2018-10-06T23:08:56.557

1

Reng v.1.3, 7 bytes

Try it out here!

"rYao;~

" begins a quote string, and reads all of those characters. r reverses the stack, and Y pushes the char code of ". a begins a one-way mirror loop, o outputs the character, and ; mirrors while the stack is truthy. After the zero is met, we advance to ~ and the program ends.

Reng v.2, 8 bytes

{n6G*o}`

This one is a little more interesting. {...} is a code block, and ` executes a code block. n outputs the codeblock already on the stack, 6G* makes a ` character (6*16 = 96), and o output's that.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

1

Java 2146 2118 bytes

A legitimate attempt at a quine. This was automagically generated. I could have robbed someone elses quining technique but decided against it.

interface q{static void main(String[] args){char[] s={32,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,125,125,32,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,125,125};System.out.print("interface q{static void main(String[] args){");System.out.print("char[] s={");for(int i=0;i<s.length-1;i++){System.out.print((int)s[i]+",");}System.out.print((int)s[s.length-1]+"};");for(char c: s){System.out.print(c);}}}

Rohan Jhunjhunwala

Posted 2011-01-28T00:34:05.293

Reputation: 2 569

1

Perl 6, 36

printf |(q<printf |(q<%s>xx 2)>xx 2)

Based on the Perl 5 quine.

bb94

Posted 2011-01-28T00:34:05.293

Reputation: 1 831

1

Julia, 36 bytes

(~=:@printf "(~=:%s)|>eval" ~)|>eval

Try it online!

Background

Unlike many other languages, Julia's eval doesn't work as expected with a string; for example, eval("print(42)") just returns the string print(42).

To actually executed print(42) with eval;, we have to pass an Expr to eval. This can be done by invoking parse on a string (e.g., eval(parse("print(42)"))) or by passing an Expr literal to eval (e.g., eval(:(print(42))).

Now, while : is a unary operator and :print works fine on its own, :print(42) does not, as it is parsed as (:print)(42), making all parentheses in :(print(42)) mandatory.

However, if we use the macro @printf instead, the parsing rules change, and :@printf(42) works as intended. Also, macro calls also do not require parentheses, and :@printf 42 saves one byte over :(print(42)).

How it works

:@printf "(~=:%s)|>eval" ~ constructs the Expr that calls @printf with the specified format string and additional argument ~. Here, ~ is simply a variable reference; the name is arbitrary.

~=<Expr> saves the generated Expr in the variable ~, which will be accessible when the Expr is evaluated.

Finally, (<assigment>)|>eval calls eval with the return value of the assignment, i.e., the Expr that was assigned to ~.

Dennis

Posted 2011-01-28T00:34:05.293

Reputation: 196 637

1

Aubergine, 21 bytes

-a1+a1=oA=Bi-BA:bB=ia   

This program ends with a trailing tab character.

Oliver Ni

Posted 2011-01-28T00:34:05.293

Reputation: 9 650

Tab character?. – CalculatorFeline – 2017-01-26T21:47:34.140

1I wrote this program in November 2015. I could have sworn I'd posted it here already. Anyway thanks for posting it and no thanks for not giving me credit. – quintopia – 2017-12-15T06:37:11.020

1That doesn't make sense, you didn't post it on here, so how would I know you already wrote it lmao – Oliver Ni – 2017-12-16T07:02:03.747

1

Scala, 56 bytes

val s="val s=%c%s%c;printf(s,34,s,34)";printf(s,34,s,34)

First defines s as val s=%c%s%c;printf(s,34,s,34), then prints it formatted with double quotes (ascii 34) and itself.

corvus_192

Posted 2011-01-28T00:34:05.293

Reputation: 1 889

1

Dart, 185 bytes

main(){var c=new String.fromCharCode(34);var l=["main(){var c=new String.fromCharCode(34);var l=[","];print(l[0]+c+l[0]+c+','+c+l[1]+c+l[1]);}"];print(l[0]+c+l[0]+c+','+c+l[1]+c+l[1]);}

Jasper Catthoor

Posted 2011-01-28T00:34:05.293

Reputation: 51

1

Dip, 10 bytes

"N+|+"N+|+

Explanation:

"N+|+"      Push string
      N+    Add " on the left side of the string
        |+  Duplicate and concatenate

acrolith

Posted 2011-01-28T00:34:05.293

Reputation: 3 728

0

Forth (gforth), 21 bytes

: x
latest name-see ;

This prints the decompiled source of the latest word, thus only works if x is the latest defined word.

Test:

x 
: x  
latest name-see ; ok

This one works without that condition, but replaces the constant definition with it's value (since that's the only thing that actually gets saved to memory)

: x
[ latest ] literal name-see ;

Test:

x 
: x  
  140121195205104 name-see ; ok

2xsaiko

Posted 2011-01-28T00:34:05.293

Reputation: 699

1If it prints with a newline in the middle, but the original doesn't have it, it's not a quine. – Pavel – 2016-12-29T05:07:04.513

Fixed. It's because there's no way to tell where spaces/newlines are as it's only compiled code – 2xsaiko – 2016-12-29T13:39:54.790

It's not a proper quine anyway, because it reads its own source. – mbomb007 – 2017-05-10T14:02:43.973

0

Pyke, 14 bytes

"34.Cp\D\Es"DE

Try it here!

"34.Cp\D\Es"   - "34.Cp\D\Es"
            DE - eval(^, stack=^)

 34.C          -   '"'
     p         -  print(^)
      \D\Es    - sum("34.Cp\D\Es", ^, "D", "E")

Blue

Posted 2011-01-28T00:34:05.293

Reputation: 26 661

0

SimpleTemplate, 56 bytes

This is a template engine language I've made for fun.

It was written in PHP and run by compiling the weird syntax to PHP.

This answer is a translation of Aurel Bílý's amazing PHP answer!

{@setF"{@setF%c%s%c}{@printF,34,F,34}"}{@printF,34,F,34}

Weird, right?

This works with the commit d1d3e2c43bd98da2bd38f884ee5ac7b39cb8c579 on my Github and you can try it on http://sandbox.onlinephpfunctions.com/code/cca9ed3b9c87abad61159725f159285e5daf9bb9.

In there, you will have the existing code on that commit, plus showing the result and the generated PHP.

Ismael Miguel

Posted 2011-01-28T00:34:05.293

Reputation: 6 797

0

GNU Make, 52 51 11 bytes

$(value $0)

When called as a function, returns its source code.

And here's a complete makefile that doesn't return its code, but rather prints it:

Q=$(info Q=$(value Q))$(info $$(call Q))
$(call Q)

Explanation

The second line just instantiates the variable, the first one defines it:

$(info Q=$(value Q))$(info $$(call Q))
         $(value Q)                     # Get unexpanded value
                           $$           # "$" escaped
$(info Q=          )$(info   (call Q))  # Print the remaining parts

eush77

Posted 2011-01-28T00:34:05.293

Reputation: 1 280

0

Babel, 161 bytes

{ "{ '{ ' << dup [val 0x22 0xffffff00 ] dup <- << << -> << ' ' << << ' }' << } !" { '{ ' << dup [val 0x22 0xffffff00 ] dup <- << << -> << ' ' << << '}' << } ! }%

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

0

Ceylon, 173 154 bytes

Saved those bytes thanks to Challenger5

shared void run(){print(let(x="""shared void run(){print(let(x=$)x.replaceFirst("$","\"\"\""+x+"\"\"\""));}""")x.replaceFirst("$","\"\"\""+x+"\"\"\""));}

source

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

You can golf off some whitespace. Try it online!

– Esolanging Fruit – 2017-05-25T01:07:44.647

@Challenger5 Cheers :D – MD XF – 2017-05-25T01:10:38.890

0

Conway's Game of Life, 7 bytes

!
**
**

Uses Plaintext format.

MD XF

Posted 2011-01-28T00:34:05.293

Reputation: 11 605

5 bytes, you missed the newline. Alternatively, in Standard Plaintext: **\n** – CalculatorFeline – 2017-05-27T23:30:34.273

@CalculatorFeline Thanks, edited. – MD XF – 2017-05-28T00:23:22.527

What interpreter are you running this in? – Post Rock Garf Hunter – 2017-05-28T20:50:15.113

@WheatWizard This is not necessarily run in an interpreter, it simply means "a 2x2 square of live cells in an empty grid". – MD XF – 2017-05-28T21:16:40.530

Languages are defined by their interpreters, if you don't have an interpreter that can take this as a source file then you can't submit this to a challenge. – Post Rock Garf Hunter – 2017-05-28T21:28:50.453

@WheatWizard Fixed. – MD XF – 2017-05-28T21:47:22.957

@Riker Nope, that's talking about the final line. This is the initial line and AFAIK it's necessary. – MD XF – 2017-06-01T17:54:13.050

1-1 this method of IO is very limited – ASCII-only – 2017-08-28T02:31:32.433

@ASCII-only since when do quines need input? – MD XF – 2017-08-29T22:57:52.783

Well this method of output mostly – ASCII-only – 2017-08-29T22:58:42.493

0

Perl 5, 37 bytes

$_=q{$_=q{0};s/0/$_/;say};s/0/$_/;say

Try it online!

mik

Posted 2011-01-28T00:34:05.293

Reputation: 208

0

ColdFusion, 276 bytes

<cfset u=Chr(34)><cfset q="<cfset u=Chr(34)><cfset q=%s%s%s><cfoutput>%screateObject(%sjava%s,%sjava.lang.String%s).format(q,[u,q,u,Chr(35),u,u,u,u,Chr(35)])%s</cfoutput>"><cfoutput>#createObject("java","java.lang.String").format(q,[u,q,u,Chr(35),u,u,u,u,Chr(35)])#</cfoutput>

I've never used ColdFusion, but after seeing @Danninta's post on Self-growing code codee codeee codeeee I thought I'd play around. This could almost certainly be golfed down by someone that actually knows the language, so feel free to add a new answer.

Tested locally on lucee-express-5.2.6.60

Dom Hastings

Posted 2011-01-28T00:34:05.293

Reputation: 16 415

0

Quantum64

Posted 2011-01-28T00:34:05.293

Reputation: 371

You might want to include an explanation, I'd be interested! Also I believe you'll need to include a newline in your code since the output of this program seems to include one as well. – ბიმო – 2018-04-10T16:34:46.537

1I assume you are the created of Jstx and the GitHub? In your documentation you mention all the possible commands/operations/functions, but not which character represents it. Since I couldn't find it in the documentation, what commands/operators/functions do these £ and represent? – Kevin Cruijssen – 2018-04-20T12:03:53.793

It's not a solid association between opcodes and bytes, and it changes from version to version of the interpreter and compiler. In fact some opcodes can actually remap every opcode to byte association at runtime. Fortunately you don't need to worry about which bytes correspond to which instructions because all the programming is done directly through instructions using the Jstx compiler, then the resulting bytes can be interpreted with the same version of the Jstx interpreter. – Quantum64 – 2018-04-21T16:53:11.303

0

PHP, 147 bytes

<?php $c= <<<'s'
	$n='<?php $c= <<<\'s\''."\n";global $c;echo($n.$c."\ns;\n".'$e=create_function("",$c);$e();');
s;
$e=create_function("",$c);$e();

Try it online!

Boian Ivanov

Posted 2011-01-28T00:34:05.293

Reputation: 41

0

VBA, 77 bytes

An anonymous VBE immediate window quine.

c=Chr(34):q="c=Chr(34):q=:?Replace(q,Chr(7),c+q+c)":?Replace(q,Chr(7),c+q+c)

Taylor Scott

Posted 2011-01-28T00:34:05.293

Reputation: 6 709

0

Ahead, 8 bytes

"34 8ko@

Try it online!

snail_

Posted 2011-01-28T00:34:05.293

Reputation: 1 982

0

Runic Enchantments, 7 bytes

"'<~S@|

Try it online!

Explanation

  <        Entry
"'         Push the " character (loop around)
      |    Mirror (loop around)
"          Begin string mode
 '<~S@|    Push the string '<~S@|
"          End string mode
 '<~       Push and pop a < character
    S      Swap stack the following also work, r: reverse, q: concatenate, +: add
     @     Print and terminate

Draco18s no longer trusts SE

Posted 2011-01-28T00:34:05.293

Reputation: 3 053

0

Tidy, 71 bytes

q:=34|chr|str;a:="q:=34|chr|str;a:=%swrite(a%%(q.a.q))"write(a%(q.a.q))

Try it online!

q:=34|chr|str gets a quote character, and a:=... defines the format string. Finally, write(a%(q.a.q)) formats a with a surrounded by quotes.

Conor O'Brien

Posted 2011-01-28T00:34:05.293

Reputation: 36 228

0

Tamsin, 67 bytes

main='->T&$:repr(T)->U&\'main=\'+U+T.'->T&$:repr(T)->U&'main='+U+T.

Ungolfed (isn't a quine, but outputs a quine):

main =  '→T&$:repr(T)→U&\'main=\'+U+T.' → T
     &  $:repr(T) → U
     &  'main=' + U + T.

Tamsin has a builtin that formats strings correctly, which makes this fairly easy.

Esolanging Fruit

Posted 2011-01-28T00:34:05.293

Reputation: 13 542

0

Tcl, 47 bytes

puts [join {p \{ \}]} {uts [join {p \{ \}]} }]

Based on Joe Miller's quine on this page.

jimmy23013

Posted 2011-01-28T00:34:05.293

Reputation: 34 042

0

C# (Visual C# Interactive Compiler), 57 bytes

var s="var s={0}{1}{0};Write(s,'{0}',s);";Write(s,'"',s);

Try it online!

There is another C# answer that uses a console application with a Main method. This approach seemed a little outdated given most current C# answers use the Visual C# Interactive Compiler. This compiler allows for a much shorter variation using the exact same technique.

dana

Posted 2011-01-28T00:34:05.293

Reputation: 2 541

0

Pip, 26 23 bytes

Y\"O"Y"ORPyy\"O"Y"ORPyy

Try it online!

Kenneth Taylor

Posted 2011-01-28T00:34:05.293

Reputation: 183

0

W, 13 bytes

Print the data string & prepend quote.

p34CS+"p34CS+

user85052

Posted 2011-01-28T00:34:05.293

Reputation:

0

Pretty certain you can't get shorter than this with Common Lisp. The first one I managed to figure out myself; all credit to http://rosettacode.org/wiki/Quine#Common_Lisp for the second one.

Common Lisp - 9 (With REPL)

(write -)

In Common Lisp, - is a special variable that holds the expression currently being evaluated but only during a read-eval-print loop. If you're running from a script or you've disabled the REPL though...

Common Lisp - 25 (No REPL)

#1=(write '#1# :circle t)

This references itself and then prints itself out. :circle t makes it detect the infinite recursion cycle and exit early.

Candles

Posted 2011-01-28T00:34:05.293

Reputation: 683

0

CJam, 1 byte

Note: CJam was made after this challenge was posted, I am posting this answer as documentation as opposed to a serious entry.

0

Pushes a 0 to the stack, and CJam automatically outputs the stack after program execution.

GamrCorps

Posted 2011-01-28T00:34:05.293

Reputation: 7 058

Don't forget newlines. – CalculatorFeline – 2017-05-28T01:39:09.793

1One part of the program does not encode another, so this program is invalid – MilkyWay90 – 2019-02-05T18:04:05.490

0

ForceLang with this module, 87 bytes

Noncompeting, language postdates the challenge

set j require njs
j var f=function(){print("set j require njs\nj var f="+f+";f()")};f()

SuperJedi224

Posted 2011-01-28T00:34:05.293

Reputation: 11 342

0

Idris, 88 bytes

q:String;main:IO();main=putStr$q++show q;q="q:String;main:IO();main=putStr$q++show q;q="

It’s like Haskell with more enforced top-level type signatures. I had to put q’s type first, because Idris’s type checker is a little weird? I dunno.

Lynn

Posted 2011-01-28T00:34:05.293

Reputation: 55 648