204
\$\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\$
  • 4
    \$\begingroup\$ Do you not mean, "Golf you a quine for greater good!"? \$\endgroup\$ – Mateen Ulhaq May 3 '11 at 2:49
  • 51
    \$\begingroup\$ @muntoo it's a play on "Learn you a Haskell for Great Good". \$\endgroup\$ – Rafe Kettler May 3 '11 at 2:52

340 Answers 340

2
\$\begingroup\$

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)
|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

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
|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

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.
|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

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

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

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
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Welcome to the site! Unary is more often called Lenguage here, but all the same. \$\endgroup\$ – Ad Hoc Garf Hunter Jan 28 at 3:04
  • \$\begingroup\$ Lenguage and Unary have different encodings (+- and >< are swapped, no extra leading 1 in Lenguage), so they're not quite the same \$\endgroup\$ – Jo King Jan 28 at 3:06
1
\$\begingroup\$

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

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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);}
|improve this answer|||||
\$\endgroup\$
  • 1
    \$\begingroup\$ You could shave 9 chars off the shorter version by leaving out the trailing newline. \$\endgroup\$ – Ilmari Karonen Feb 3 '12 at 18:55
1
\$\begingroup\$

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

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Tcl, 61 chars

set c {set c {$c};puts [subst -noc \$c]};puts [subst -noc $c]
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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])}
}
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ this is awesome. \$\endgroup\$ – cat Dec 7 '15 at 14:50
1
\$\begingroup\$

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)
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Scala, 84 bytes

val d="""
print("val d=\"\"\""+d+"\"\"\""+d)
"""
print("val d=\"\"\""+d+"\"\"\""+d)

Kinda straightforward, but putting it out there for completion.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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

`è";ƒ"@+`;ƒ

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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)))
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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));}}
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Tom Hawtin - tackline Oct 6 '18 at 23:08
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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);}}}
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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)
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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]);}
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Dip, 10 bytes

"N+|+"N+|+

Explanation:

"N+|+"      Push string
      N+    Add " on the left side of the string
        |+  Duplicate and concatenate
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Zetaplex, 13 bytes

"Sr34SZOsDrFe

Zetaplex is a variant of gammaplex. In it, commands are pairs of chars and act on an infinite stack.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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 :!.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Note simply 3 works too, but that is too much of an obvious reading-from-the-source. \$\endgroup\$ – devRicher Dec 26 '16 at 22:33

Your Answer

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

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