244
\$\begingroup\$

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> 

\$\endgroup\$
3
  • 6
    \$\begingroup\$ Do you not mean, "Golf you a quine for greater good!"? \$\endgroup\$ Commented May 3, 2011 at 2:49
  • 64
    \$\begingroup\$ @muntoo it's a play on "Learn you a Haskell for Great Good". \$\endgroup\$ Commented May 3, 2011 at 2:52
  • 26
    \$\begingroup\$ Did anybody notice that this is question 69? \$\endgroup\$
    – aidan0626
    Commented Oct 24, 2020 at 22:47

455 Answers 455

1
5 6
7
8 9
16
4
\$\begingroup\$

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!

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

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
]
\$\endgroup\$
4
\$\begingroup\$

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.

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

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
\$\endgroup\$
4
\$\begingroup\$

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$
\$\endgroup\$
4
  • 2
    \$\begingroup\$ please make the main part of the post the 55 byte noncheating quine \$\endgroup\$ Commented Oct 14, 2016 at 21:05
  • \$\begingroup\$ Done. I wonder why using 'SOURCE$' is cheating, looking at the other contributions? \$\endgroup\$
    – Peter
    Commented Oct 15, 2016 at 20:05
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Dennis
    Commented Oct 15, 2016 at 20:13
  • \$\begingroup\$ Thanks for pointing me to this page, I was unaware of it. \$\endgroup\$
    – Peter
    Commented Oct 16, 2016 at 20:29
4
\$\begingroup\$

MAWP, 60 bytes

Thanks @JoKing for saving a whopping 55 bytes!

48923792915350878792773358929392915992930\%\[52WW\M!:\]\[;\]

Try it!

It's finally done!

Explanation:

The quine is essentially split into three parts. The first part is the data, and is represented by the big blob of numbers in the start (excluding a 0). It represents the ASCII codes of the rest three parts of the code. The second part is the decoder that both turns the long stack of separate numbers into a smaller stack with multi-digit numbers and prints it as numbers without destroying it. The last part loops over the stack and prints it as ASCII. Note that we don't have to preserve the data in stack any more.

Old solution:

115 bytes

481263753508787774753508787775350878777479153508787774793479133584793479159930~%52WWM/52WWM52WWM/[52WWM/]/[!:/]/[;]
\$\endgroup\$
7
  • \$\begingroup\$ @JoKing - the auto-pasting of the code in the link doesn't seem to work (at least for the Mac OS X browsers that I've tried), and it's difficult to extract the code from the link itself. Could you include the code itself in a comment? \$\endgroup\$ Commented Aug 17, 2020 at 7:53
  • \$\begingroup\$ @DominicvanEssen could you possibly describe the issue with the auto-copy on the interpreter? I myself work on a Mac, but had no issues developing and testing everything, as so do others who use the interpreter. \$\endgroup\$
    – Dion
    Commented Aug 17, 2020 at 8:57
  • \$\begingroup\$ @JoKing - Thanks! @Dion - When I click on your link (or that of JoKing) in either Chrome or in Firefox, I get the 'MAWP version 1.1 (latest)' web page, but the 'code:' box is empty. In Chrome I can manually copy-paste the code into the box, and it then works fine when I click 'Run code', but it's difficult to get the code out of the link because many of the characters are represented with %s. FYI, I just tried to generate my own link (using the 'generate link' button after pasting-in your code), and this link also opens an empty 'code:' box. Hope this helps.... \$\endgroup\$ Commented Aug 17, 2020 at 15:57
  • \$\begingroup\$ @DominicvanEssen if it doesn't trouble you, would you mind and telling me two things: a) are the query's in the links empty b) does the dev console show any errors on loading and/or link generating? Thanks! \$\endgroup\$
    – Dion
    Commented Aug 17, 2020 at 16:00
  • \$\begingroup\$ @Dion - I'm not a developer so I'm rather out of my depth here, but I'll try to answer. Let me know if I haven't told you what you need to know. The link seems to contain the program (it ends with .../?code=481...b%5D&input=, but the program doesn't end-up in the 'code:' box. I don't really know what the 'dev console' is, but (in Chrome) I clicked on 'View>Developer>Developer tools' and selected the 'console' tab, and there are no errors displaying (either for loading or creating links). \$\endgroup\$ Commented Aug 17, 2020 at 16:11
4
\$\begingroup\$

Perl 5, 21 bytes

say<<""x2
say<<""x2


Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Woah, not sure how I missed this. This is awesome! \$\endgroup\$ Commented Aug 19, 2021 at 8:13
4
\$\begingroup\$

V, 4 bytes

2i2i

Try it online!

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.

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

ShapeScript, 16 bytes

'"%r"@%"0?!"'0?!

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.
\$\endgroup\$
4
\$\begingroup\$

Vyxal, 57 bytes

2996557859220556162530996767470:`0123456789+:`\\\`\τ+++τ+

Try it Online!

The big number at the front is the rest of the program encoded using the key 0123456789+:τ\ with a backtick (dammit markdown). The rest of the program constructs the key, decodes this, and concatenates the original number to the result.

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

Klein, 13 + 6 = 19 bytes

Martin Ender has made a shorter 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.

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

Zsh, 37 bytes

s=s=%q\;printf\ \$s\ \$s;printf $s $s

Attempt This Online!

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

Perl 5 + -p0513, 29 bytes

s<><s<><@>;s/@/lc/e>;s/@/lc/e

Try it online!

Explanation

s<><               >;         # Working with `$_` by default, `s`ubstitute (`s///`, but using 
                              # `<><>` instead of `///` to allow nesting) the empty string...
    s<><@>;s/@/lc/e           # ...with the body of the quine.
                     s/@/lc/  # Then, again working with `$_`, replace the first `@` with `lc`...
                            e # ...and execute the result (calling the sub `lc` which returns its
                              # argument, or `$_` if no argument is passed) `l`ower`c`ased, which
                              # in this case is the body of the quine.
                              # `$_` is then finally `print`ed because of `-p`.
\$\endgroup\$
2
  • \$\begingroup\$ I can somewhat get the other quines, but somehow Perl always manages to elude me. \$\endgroup\$
    – Razetime
    Commented Sep 17, 2020 at 5:42
  • 1
    \$\begingroup\$ @Razetime This particular one is a little tricky because it breaks out of the (implicit) while(<>){...} from -p first and then uses nesting chars for s/// (s<><> in this quine) and uses @ as a positional argument (like %s in the printfstyle quines). The final piece is using lc for a reference to $_ as everything would be unchanged by lowercasing. If I get time today I'll annotate this one properly too! \$\endgroup\$ Commented Sep 17, 2020 at 6:04
4
\$\begingroup\$

SQLite, 66 bytes

SELECT PRINTF(s,s)FROM(SELECT'SELECT PRINTF(s,s)FROM(SELECT%Qs)'s)

Try it online!

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

Malbolge, 59851 Bytes

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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NPkVd+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>

\$\endgroup\$
7
  • \$\begingroup\$ Please note that Community Wiki is not a rep waiver so there is no real need for you to have marked it as such. \$\endgroup\$
    – MD XF
    Commented Jun 14, 2017 at 2:54
  • \$\begingroup\$ Unless my clipboard is playing tricks on me, your snippet shows only 46485 characters. \$\endgroup\$
    – Dennis
    Commented Jun 25, 2017 at 22:29
  • \$\begingroup\$ @Dennis Snippet is compressed \$\endgroup\$
    – ATaco
    Commented Jun 25, 2017 at 22:30
  • \$\begingroup\$ Yes. I copied the output of the Stack Snippet. Copy-pasting from the original website works fine btw. \$\endgroup\$
    – Dennis
    Commented Jun 25, 2017 at 22:32
  • \$\begingroup\$ The problem is most likely because of whitespace and/or HTML escapes. .html won't work properly for a div. \$\endgroup\$
    – Dennis
    Commented Jun 25, 2017 at 22:37
4
\$\begingroup\$

Jellyfish, 67 53 32 bytes

PvxP,"DC!�$Vp~V*Z$
BE'"PvxP,\"

note: � in the 1st line is a NUL char ( ASCII 0 ), and in the 2nd line an ACK char ( ASCII 6 ) exists ( but looks hidden ) between a single quote and a double quote.

Try it online!
Try the 53B version online!
Try the 67B version online!

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

Trilangle, 15858 5562 characters, 15950 5654 bytes

Nowhere near as short as the others but it finally works! Posting what I have before attempting to get it shorter.

Edit: I think that's the most extreme golf I've ever had in a single go.


The program consists of two interesting sections separated by 5329 periods (.):

\\!.(2."!L.2'7!..2j.++!"%_".#:_",oI#.!"%_"2..._",o+..S#\(,o+!":.,##,o."<!L*2/!..2,,<><#..(!(,oj)2_,o""<!L#"!B!!B!!B!!><#2"!B!!B!!B!!@"!!7!

and

"ᘠ"𥧷"l"𥱏"࠰"𥰱"𖖦"⍋"㩇"𷈤"𘑨"喨"⍎"㩇"𜼱"㩐"𗶇"񮞒"𐲮"𗶇"𷆸"䪤"򬇥"𻡇"𔴾"Ճ"𥰱"𻯻"傤"ﮧ"𘙤"𓕭"𙫞"⏮"񞰆"a"!"!"!"傤"p"!"!"!"~"ࠪ".

The second part contains unallocated Unicode codepoints, so I can guarantee that your font doesn't have them all. It's the first part encoded in base-95, three instructions per character, length-suffixed.

To scale, the full program looks like this when unfolded:

A screenshot of vs code showing a very zoomed-out program. The very top is labelled "Decoder". The very bottom is labelled "Data". Most of the program is labelled "big-ass NOP slide".

The decoder does three things, in order:

  1. Decode the data from base-95 and print it. I use ! for zero rather than because the interpreter ignores spaces. In hindsight I could've done base-94 but that's still only 3 instructions per character, so it wouldn't make a massive difference.
               \
              . ( 2
             .     L
            . 2 ' 7  
           . . 2 j   +
          + ! " % _ " .
         # : _ " , o    
        . ! " % _ " 2   . 
       . _ " , o + . .   
      \ ( , o + ! " : .   
  1. Print 5329 periods.
                  7
                   .
                    "
                     I
                      .
                       S
                        ,
     # , o . " <   L * 2 /
                > < # . . ( !
  1. Print the whole stack, alternating with " characters.
    . . 2 , , < >
   ( , o j ) 2 _ , o " " <   L
                          > < #
                         @

Most of the !s, some of the "s, and all of the Bs are never hit. They're just what the decoder produces at those locations. ! and " are used because they're 0 and 1 in base-95, respectively, and B is used because B!! is the smallest triplet that corresponds to a printable non-whitespace character.

This can obviously be compressed by making the NOP slide smaller. There's two ways to do this, one easier than the other:

  1. Be a bit smarter about computing the size of the NOP slide. I gave myself very little room to do so and so the only thing I could come up with was "I2*, i.e. \$73^2\$. Rearranging some other things to give myself more room to compute this value means I could move the data closer to the decoder.
    • Partially addressed by edit 1: 15625 -> 5329. This is the smallest square that will work, but there's a smaller non-square number. I only got the absolute lowest-hanging fruit.
  2. Be a bit more clever about how the stack is printed, so that it doesn't have to be all on one line. This brings the amount of NOPs needed from \$O\left(n^2\right)\$ to \$O(n)\$ if you do it right, I think. See Bubbler's suggestion in chat the other day. I can definitely do this, but it'd take a bit of thinking.

Like I said, I'm just posting this for now to be on the board. I'll have to revisit this to make it shorter.

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

Uiua, 14 bytes

&s&pf."&s&pf."

Try it Online

RTL evaluation made this way more easier than it could have been.

Explained

&s&pf."&s&pf."­⁡​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌­
      "&s&pf."  # ‎⁡Push the string "&s&pf."
     .          # ‎⁢Duplicate it
  &pf           # ‎⁣Print without newline
&s              # ‎⁤Print repr version
💎

Created with the help of Luminespire.

\$\endgroup\$
5
  • \$\begingroup\$ Alternative 14: ⊃&s&pf"⊃&s&pf" \$\endgroup\$ Commented Mar 9 at 17:26
  • \$\begingroup\$ 13 bytes, somebody in the uiua discord has 11 \$\endgroup\$ Commented Apr 15 at 11:39
  • \$\begingroup\$ actually i think this solution is 15 because it should have a trailing newline, and mine is 14 \$\endgroup\$ Commented Apr 15 at 11:40
  • \$\begingroup\$ @noodleman it worked well in earlier versions \$\endgroup\$
    – lyxal
    Commented Apr 15 at 12:47
  • \$\begingroup\$ Yeah that probably checks out \$\endgroup\$ Commented Apr 15 at 14:57
4
\$\begingroup\$

JavaScript (Node.js), 38 bytes

console.log(s='console.log(s=%o,s)',s)

Attempt This Online!

This seems to be the shortest non-function-stringifying JavaScript quine. Unfortunately seems to be platform-specific: it works as-is in Chrome and Node.js, but in Safari requires the single quotes to become double quotes.

In a strict-mode setting like Deno, you need to declare var s; at the start:

var s;console.log(s="var s;console.log(s=%o,s)",s)

Bun doesn't seem to support the %o directive in any form.

\$\endgroup\$
3
  • \$\begingroup\$ I just tried this on Safari, it works if you replace the single quotes with double quotes. \$\endgroup\$ Commented Oct 19, 2023 at 16:59
  • \$\begingroup\$ This seems to be V8-specific; in Firefox/SpiderMonkey it uses spaces instead of quotes in the output. \$\endgroup\$
    – Bbrk24
    Commented Oct 19, 2023 at 18:33
  • \$\begingroup\$ @Bbrk24 That's what I thought before, but I tried it on Safari (JavaScriptCore) and it works with single quotes, so I think it's tied to the runtime rather than the JS engine itself. \$\endgroup\$ Commented Oct 19, 2023 at 18:51
3
\$\begingroup\$

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));}}
\$\endgroup\$
2
  • 4
    \$\begingroup\$ You 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) \$\endgroup\$
    – Justin
    Commented Dec 11, 2013 at 23:51
  • \$\begingroup\$ @Justin Technically, 12 bytes saving. \$\endgroup\$
    – driima
    Commented Nov 1, 2016 at 8:59
3
\$\begingroup\$

(ucb)logo - 28 chars

to q
po "q
pr "q
bye
end

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

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)];
\$\endgroup\$
3
\$\begingroup\$

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.

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

Pyth, 11 bytes

jN*2]"jN*2]

Surprised this hadn't been posted yet :P

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

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
\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
10
  • \$\begingroup\$ It's cheating if b is your whole program. However, if b is a function or string literal, it's fine. \$\endgroup\$
    – wizzwizz4
    Commented Feb 14, 2016 at 9:05
  • \$\begingroup\$ @wizzwizz4 Thanks for the clarification! \$\endgroup\$
    – fede s.
    Commented Feb 14, 2016 at 21:56
  • \$\begingroup\$ Yeah sourceString looks like "read[ing] the source file and print[ing] it". \$\endgroup\$ Commented Feb 14, 2016 at 22:34
  • 1
    \$\begingroup\$ The second largest program I've seen. 91! = 1.352002e+140 :P \$\endgroup\$
    – user48538
    Commented May 16, 2016 at 20:29
  • 1
    \$\begingroup\$ @fedes. probably needs more jQuery \$\endgroup\$
    – cat
    Commented May 17, 2016 at 23:23
3
\$\begingroup\$

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!

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

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>

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

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;
\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ 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. \$\endgroup\$
    – JDL
    Commented Aug 25, 2016 at 14:17
  • \$\begingroup\$ A more trivial example is function()1 (11 bytes) but that's kinda boring... \$\endgroup\$
    – JDL
    Commented Aug 26, 2016 at 14:06
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – JayCe
    Commented May 16, 2018 at 17:56
  • \$\begingroup\$ 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! \$\endgroup\$ Commented Jan 31, 2019 at 15:37
  • \$\begingroup\$ yes, list() (and numeric(0) and friends) are all quines in R. \$\endgroup\$
    – JDL
    Commented Feb 1, 2019 at 8:57
1
5 6
7
8 9
16

Your Answer

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

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