# Golf you a quine for great good!

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;

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}
body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)
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> 

• Do you not mean, "Golf you a quine for greater good!"? – Mateen Ulhaq May 3 '11 at 2:49
• @muntoo it's a play on "Learn you a Haskell for Great Good". – Rafe Kettler May 3 '11 at 2:52

# Hexagony, 261 bytes, side length 10

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


Try it online!

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

Formatted, this looks like:

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


Try it online!

Some python-like psuedo-code to explain:

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


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

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

• What a shame this doesn't fit in 108 digits. – NieDzejkob Sep 22 at 9:51

# dc - 16 characters

[91PP6120568P]dx

• There's this for 10: 6581840dnP – Digital Trauma Feb 26 '15 at 22:22
• I knew you could print a character based on an ASCII code directly or a number % 256, but not a string using the coefficients of a base 256 polynomial as individual characters. Awesome! – seshoumara Sep 7 '16 at 10:05
• Same length: [91PP93P[dx]p]dx (taken from Reddit) – mbomb007 Oct 26 '16 at 14:53

## Perl, 30 28 chars

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


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

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

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

• This is the shortest Perl quine I'm aware of (which doesn't read $0, that is). – primo Jun 20 '13 at 12:43 # Stax, 10 4 bytes ..SS  Run and debug online! I have long believed that the 10-byte quine cannot be any shorter until I happen to come across this one while doing another challenge. This one is not extensible while the 10-byte one is. ## Explanation ..SS ..S The string ".S" S Powerset, in dictionary order if the original string is ordered In this case, generates [".",".S","S"] Implicit flatten and output  ## Old version, 10 bytes "34bL"34bL  Run and debug online! Added for completeness. I thought this is the shortest proper quine in Stax, but the idea is not that exciting and has been extensively used. I tried to come up with a more interesting (but longer) solution but so far to no avail Now there is one, it's even shorter than this. I would also be happy to offer a bounty to a proper quine in Stax in the packed form. ## Explanation "34bL" Push that string 34 Push the quotation mark b Duplicate both elements on stack L Pack all elements to an array Implicit output  Finally, an improper quine: |? Source of the program  or just 0 Implicitly prints the 0 on the top of stack  ## Fob (135) In Fob, a language of my own creation from some time ago, I present a rather interesting 135-byte quine: $$#<&::#<&:#<&#<&:#<=#<&&//%<//<.&%<<%.%<&>/////%<<%.<&.%<.%/////<&.%<<&/.%%<&>%</%<////<&.%<<%/<&.%%<&>/%//<&.%<</&.%%%<&>>/>>#<=  • "If Fob, a lan" – CalculatorFeline May 25 '17 at 1:17 # ><> (Fish) - 8 chars Prints itself but throws an error "r0:g>o<  13 For no error (old Fish) "r0:g!;>?o?|;  15 if you think g is cheating "r1b3*+!;>?o?|;  • Last two ones don't work for me. They output rg>? and r3!?|, respectively. They seem to skip two characters every time... – tomsmeding Apr 22 '13 at 5:55 • @tomsmeding I think the interpreter changed some point after this answer, hence the (old fish) in parentheses. Though I honestly can't remember it was 2 years ago. I know they worked when i posted my answer. – cthom06 Apr 22 '13 at 13:19 • In old fish the ? command did not pop the stack, new fish does – JNF May 27 '15 at 18:53 • I would suggest, for new ><>, "r0:g>o_!~l?!;!_|, or "r13b*+>o_!~l?!;!_| for no g version (which I don't view as cheating anyway...). But then you're not better off from "r00g!;oooooooo| (16) – JNF May 27 '15 at 20:57 • I've been looking at this for a little bit (longer than I should have!) and I've come up with this quine which errors but doesn't use g; #o<}-1:" respectively; #.09;!?lo}-1:" for the non error one. being 8 bytes and 14 bytes. – Teal pelican Dec 19 '16 at 14:33 # Haskell (50 characters) main=putStrq++show q;q="main=putStrq++show q;q="  ## Python 3, 54 I have never seen this one before, so here's my fair creation. It is longer than the classical one but it is a single expression. print(str.format(*['print(str.format(*[{!r}]*2))']*2))  • btw, this is 2 bytes shorter in Python 2, where you don't need the parentheses after print. – flornquake Sep 15 '14 at 9:40 • @flornquake Then wouldn't it be four bytes shorter, because of the print(...) within the string? – HyperNeutrino Feb 11 '16 at 23:59 • @Alex No, because you need to add a space after each print. – flornquake Feb 20 '16 at 23:04 • @flornquake Right. Thanks. Also, nice username. It's interesting. – HyperNeutrino Feb 21 '16 at 2:44 # Dodos, 1743 1722 1380 1360 1340 1155 1120 1105 1095 1075 985 bytes  o d o e d o a 3 p o > > p u = u = = = > u e * * - = e > a dot > dab b b dip = a b m m a > a i a + = > * = b + dip = b - i i + . i - 2 i i i i . 3 i 2 5 i 3 d * * 3 - * * 2 - * + * * 3 - * * 2 . * * 2 - * + 3 - * + * * 2 * * * - 3 * * 3 . * + * * 3 - * * . 3 * * . 3 * + 3 . * + * * 3 3 * * . 2 * + * * 3 3 * * . 2 * + * * . 2 * + * * . 2 * * . 3 * + 3 3 * + * * * + * * * + * * * + * * * + * * * + 2 . * + * * - * * * - * * * - - * * . 2 * + * * 2 . * * . 3 * + 2 * * + * * 2 - 3 - 3 2 * + . 3 * + * * 2 - 2 * 2 + * + 2 + * + * * 2 + * * 2 - 2 2 3 . * + . 2 * + * * 2 * * * 2 + * * 3 + * + 3 + * + * * 2 * * * . 3 * + * * 2 * * + 2 2 * + * * 2 * * * - + * * . 2 * + * * . 3 * + - * * + * * . 2 * * 2 + * + * * * + - + * + * * 2 - 2 2 3 . * * . 2 * * 2 + * + * * * + - - * + * * 2 2 * * 2 2 * * - + * + - . * + * * 2 2 * * - - * + - 2 * + * * 2 2 * * 2 2 * * 2 2 * * 2 2 * * - . * + - 3 * + * * 2 2 * * - 2 * + . * * + * * 2 2 * * - 3 * + 2 - * +  Try it online! • Why did you use tabs instead of spaces in the last line? – user202729 Mar 18 '18 at 1:31 • It's easier to print here, because I have a function - that prepends 9 to the argument vector. – Dennis Mar 18 '18 at 1:39 • And now it's all tabs, because encoding the encoded data is shorter than printing it directly. – Dennis Mar 19 '18 at 2:16 # Cubically, 191143136577911637982432301 23782 bytes bzip2 base64: QlpoOTFBWSZTWSMgFToABO/+gH+v8Axh+v8AxgYAoIAKQAJdwKuVzgxQ1MUB6hoA0GmgGgJT1FTQ no0T1BgEBkwhgmqSlP0SaekAAANDNNR6giUSNI9IwgYmRiYGk0bAN0SBGEAgAwipuIKA7IAr0BT8 fTJaxJTd/OTv5dAU375w7dKpPdcgU38W3ZxzMysszgCmq8dVJjeCn61Wa1tmVmZ1gplc94KanXgK cOAKeeFeHf2XHWrLMyzN2ta1qzWZbvDa2srdncCnMFMvDqBTOflgU0CmgU6gU1rcqk8cmYtCraEq FKwAEaKqDciINVVTgCm214pJTKFMjGGprIlgQhSh8AAjdcACPWrfws5fs4KwtZFUULGPlBwWUWQo qGxI64evL2PCZJmSklppgmpiUlBJkhQFgWAlKaYCS+ygDZJECsG+CYIJIAVi+p1vkyE47sxkphLQ aCIqikSFBkERl6ftt99xKSQE0Q4IhIkVmlYztSX3HWMA+VMsrqrboe70pOhdF17QtcGYNScpPTPc lIkkgGc4wjB9xJJp/Xd/blx283P0/I2BTsBTmqkxVJ0BTf3YCnTr7QU/4u5IpwoSBGQCp0A=  Try it online! At least it is obviously possible. Didn't try v1.3 yet. The official interpreter seemed to be lying about that it supports SBCS. But I managed to get it working in Unicode mode. ### Generator in CJam { e#"«»"[129 130]er "«»"'Â1f+ers }:U; { N-U:i_0=\2ewWf%::-+ { _g:M; [z [[36 5] [29 4] [25 2] [23 1] [21 3]] {~@@md\@s*\}/ _11>{3 21@-])\s_M" +-"=\+e&\0s*_M" -+"=\+e&+}{0s*]s_M" +-"=\+e&}? '@ }%s }:F; [ "" "M2E ( !0{LDL'" "}))"F "&} M-" "" "*1(6/1+" "" "*1 !0{?6{*11LDL'" " ?0{/4+11@_} !0{(6*11+33@/11-4)} }-1 !6{+":QN-F "LD'L'/11}} !6{+" ]_sN- U,24md23\-'+*@0@t4 2)"3"*t6@)"3"*t sN- _U{i32-"4"*QN-}/"}))"  ### Pseudocode Loop i in {1,2,3} If i = 3, output "}))" and exit n = -1 - length before the first +1+1+1+1+... Loop while n != 0: n += 1 + length before the first +1+1+1+1+... If i = 2, output the code corresponding to the following pseudocode: " If i = 1, output n as a character If i = 2, output "+1" n times n-- If n = 0: n = " If n = 0: n = +1+1+1+1+... (the first character) If i = 1, output n as a character If i = 2, output "+1" n times n-- If n = 0: n = +1+1+1+1+... (the second character) If i = 1, output n as a character If i = 2, output "+1" n times n-- ...  n is stored in the register called "notepad". i is stored as cube positions. The first version has used a 1 in one face to print numbers. The latest version simply add whatever number in one face and divides by it. There are two ways of printing a string preserving the register. One way is to multiply by 16 or 32 two times, the other is to shift left by a small number. The cube position had to be chosen carefully to get a small enough number in the first version to prevent overflow. But after it is golfed it almost always works. • So... how many chars are there in the program? – user202729 Mar 18 '18 at 1:23 • Somewhat similar to the Mini-flak quine. – user202729 Mar 18 '18 at 1:33 • The official interpreter seemed to be lying about that it supports SBCS. shhhhh :P but congrats on winning the bounty! – MD XF Mar 20 '18 at 3:21 • Yeah, it was lying. I'm too lazy to go fix the repo so I'll delete the meta post until it's fixed. – MD XF Mar 20 '18 at 3:31 • @jimmy23013 I'll give you a +100 bounty on another post in honor of this one. (Dennis has said this is allowed.) – MD XF Mar 23 '18 at 3:52 # Triangular, 18337 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828<> HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp...HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH  Since this contains un-printables here's a pastebin. Try it online! ## Explanation Here is the relevant portion of the code with a line breaks where they would be inserted:  ,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828< > HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp...HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH   The Hs are there because they are easier to print than ., but they have the same function, so I'll replace them and all the other noops with .:  ,94942339352462393733242422402282678746947594827594678246942219941994753536322424463225469422223987242539322425469475943836248282228238392446947594383433242467274646946730621520949494282828< >................................................33pp)95*P973**(:(dUi@p]pd]pUd@p(%p%p]562**@2+@p((9i*+92*+@p]p86*dd(d89*@p]p843**U-@@pU0P!&ppp.................................................   Like most quines this comes in two parts, an encoder and a decoder. The encoder is the line full of numbers and the decoder is the line full of symbols. Each pair of numbers in the encoder represents a single character in the decoder. Once we have encoded we get pushed down to the decoder. The first thing in the encoder (besides 33pp which is just there for spacing) is ). This tells triangular to jump back to the start of the most recent loop. However since we have not opened a loop there is nothing to go back to so it does nothing. This will be used later to yoyo the ip when we don't want it to run the decoder. We then store - to the register with 95*P, this will be used to create both , and .. We then push 189 which is the number of blank lines before the code starts. We use this and a loop to generate all the empty lines before the code starts. (:(dUi@p]pd]  Once our loop is done we add the , with pUd@p. Now we are ready to decode the encoder, this is done with the simple loop: (%p%p]  Each %p prints one of the numbers off the top of the stack. We have two of them because some of the numbers have zero as their second digit, meaning in order to get the loop to go through all the encoder we need to print them two at a time. Once the encoder has been printed we print <> which makes up the two redirects that are needed. 562**@2+@p  Now we need to fetch another copy of the encoder. To start we open a loop with ( this will be closed by the ) we encountered earlier allowing us to spring back to where we were first. But first we have to run through the decoding section once. The decoding section combines the two numbers as a double digit number in base 10 and adds 18 to the result, since our stack is currently empty this will decode to 18 directly. Thats what accounts for the unprintable in the quine. Once we have "decoded" a character we run through the bit of the program that creates the padding, we make half the padding and leave the other half to be made later. Next up we is the code that makes the backticks. Since we absolutely cannot have any of these just lying around we subtract the register from the result to makes some significantly less harmful 3s. Lastly we use the check the contents of the register, exiting on zero. Since we don't have anything we continue on for later. In order to make sure the next run does terminate we put a 0 in the register. The ip runs through the encoder again and gets yoyo'd back to our decoder again. Now we are ready to decode everything. The first loop (9i*+92*+@p]p  Converts to base 10 adds 18 and outputs, it does this until we have emptied the stack. Next up we create the padding. We already created half the padding the first run through so we only have half left. 86*dd(d89*@p]p  Once again we pad with H because its cheaper to make than . in this situation. Now we make the backticks. We make them using 843** and subtract the contents of the register using U-, since we previously set the register to zero we output backtick this time. Now we exit by checking the contents of the register: U0P!&  (there are also 3 ps at the end of the code, I don't know why they need to be there but they do, a bunch of weird characters end up in the output otherwise) # 7, 2 (or 1⅞ or 1⅝, depending on how you count) bytes 7 is an Underload derivative that I've been working on over the past few days. Being an Underload derivative, it's particularly good at quines, so I thought I'd come to this challenge first. (Unlike Underload, though, it has support for input. Like Underload, it's Turing-complete, thus meaning it can handle all the tasks required to be an actual programming language.) The program itself can be expressed either in octal encoding (there are only 8 commands, named 0, 1, 2, 3, 4, 5, 6, and 7, that can appear in a 7 source file): 23723  or packed into bytes (the language sees them as raw octets; I've expressed them as codepage 437 here): Oº  (The interpreter ignores trailing 1 bits, so arguably this program can be golfed down to only 13 bits = 1⅝ bytes long via removing the language's equivalent of "trailing whitespace". Languages like this are a little hard to count.) Here's how the program works. 2 encodes "duplicate", 3 encodes "output and pop twice", thus the combination 23 means "output and pop". The program will thus start by pushing two 23 units on the stack (these are initially inert, but become active as they're pushed). Because the end of the program was reached, it's replaced by the top stack element, without disturbing the stack; thus the text of the second 23 gets output and popped. (As it's active rather than inert, what actually gets output is a string representation, 723, but the first 7 is interpreted as a formatting code that specifies "the output should be in the same encoding as the program itself", meaning that the quine works in both encodings.) Then the same thing happens for the first 23; this time, the whole 723 gets output, leading to an output of 23723 (or Oº). This is a true quine via all the definitions we commonly use on SE. For example, the first 23 encodes the second 23 and vice versa, meaning that part of the program encodes a different part of the output. Likewise, this quine could handle a payload just fine. If you didn't require a true quine, you could use the following ⅜-byte program: 3  which is a proper quine by some definitions, but not others. (The stack starts with two bars on it, meaning that the extra pop that occurs after the output is printed is harmless.) • codegolf.stackexchange.com/a/55943/42545 I should've implemented it sooner ;-) – ETHproductions Dec 4 '16 at 4:32 • Not really a big deal to have two languages with the same name. It's happened before. – user62131 Dec 4 '16 at 4:34 • You can only claim byte counts that are supported by an implementation. Unless 7 is implemented on a system that stores raw bits, the byte count for this answer should be 2. – Dennis Dec 6 '16 at 19:13 • @Dennis: The language's implementation ignores any 1 bits at the end of the program, throwing them away as it reads them; they're just padding to allow the language to be stored on a disk (in much the same way as some older computer systems couldn't read files in units smaller than, say, 80 bytes). Do you consider that to count? – user62131 Dec 6 '16 at 19:48 • I'll mark it as 2 bytes for the time being, then, but this probably deserves a meta post of its own for discussion. – user62131 Dec 6 '16 at 19:55 # Amazon Alexa, 31 words Alexa, Simon Says Alexa, Simon Says Alexa, Repeat That Alexa, Simon Says Alexa, Repeat That Alexa, Simon Says, Alexa, Repeat That Alexa, Simon Says Alexa, Repeat That Alexa, Simon Says quiet  (each command is on a newline) When said out loud to a device with the Amazon Alexa digital assistant enabled (I've only tested this on the Echo Dot though), it should say the same words back to you. There will be some different lengths of pauses between words, as you wait for Alexa to reply, and it says everything without breaks, but the sequence of words are the same. ### Explanation: Each line is a new Alexa command, one of either: • Alexa, Simon Says ..., which will prompt Alexa to say everything afterward the command • Alexa, Repeat That, which repeats the last thing Alexa said (neither of these appear on most lists of Alexa commands, so I hope someone has actually learned something from this) We can simplify this to the commands S and R respectively, separated by spaces. For example, SR will represent Alexa, Simon Says Alexa, Repeat That. The translation of our program would be: SS R SRSRS R SQ  Where Q is quiet (but can be anything. I chose quiet because that's what Alexa produced when I tried to give it quine, and it fit, so I kept it). Step by step, we can map each command to the output of each command: Commands: SS Output: S Commands: SS R Output: S S Commands: SS R SRSRS Output: S S RSRS Commands: SS R SRSRS R Output: S S RSRS RSRS Commands: SS R SRSRS R SQ Output: S S RSRS RSRS Q Total Commands: SSRSRSRSRSQ Total Output: SSRSRSRSRSQ  The general approach for this was to get the output ahead of the input commands. This happens on the second to last command, which gets an extra S command. First we have to get behind on output though. The first two commands SS R only produce SS, leaving us to make up the R. However, this allows us to start a S command with an R, which means we can repeat a section (RSRS) multiple times, which allows us to get the spare S leftover. After that, all we had to do was use it to say whatever we wanted. • Can Alexa do addition and primality checks? If so, then Alexa is a programming language according to PPCG – MilkyWay90 Mar 26 at 0:27 • @MilkyWay90 Yes, Alexa can do both those things, but I still hesitate to call it a programming language since those are both "built-ins", and Alexa is incapable of basic data storage and input. – Jo King Apr 15 at 5:49 • This is really a nice idea, but i don't think that it would be a valid quine if it is a valid programming language. In a valid quine, the spaces (or pauses) must also be the same, so if you had a second Alexa which only hears the output of the first Alexa, it should say the same as the first Alexa for a valid quine. The different pauses lead to different commands. You enter S("S"); R(); S("RSRS"); R(); S(); and you get S(); S(); R("SRS"); R("SRS"); – Dorian Jun 3 at 11:00 • I disagree. Each line of a quine isn't required to output itself. In an arbitrary scripting language, A\nB\n would be a valid quine even if A output nothing then B output A\nB\n. most multi-instruction quines don't output anything until the last line [of each loop]. – Sparr Sep 24 at 18:49 ## JavaScript, 31 characters function f(){alert(f+"f()")}f()  Is this seriously the shortest JavaScript quine here? • 75, without recursion: !function (x){alert('!'+x+'('+x+')')}(function (x){alert('!'+x+'('+x+')')}) – sdleihssirhc Oct 27 '14 at 5:12 ## TI-BASIC i  Where i is the imaginary number • -1. That doesn't actually print 2i outside of an interactive console, does it? – nyuszika7h Apr 26 '14 at 15:27 • @nyuszika7h Yes it does. 2i works as a program that, when run, prints 2i (because the last line that sets Ans is automatically printed). – Timtech Apr 26 '14 at 16:40 • @nyuszika7h Please test or research before downvoting. – Timtech Apr 26 '14 at 16:41 • Well, now I can't undo my vote unless this answer is edited. But then couldn't you just use 2 for a 1-byte solution? – nyuszika7h Apr 27 '14 at 17:46 • @Timtech The goal is to write the shortest quine. – mbomb007 Sep 14 '15 at 21:38 # Ceylon 16471165885739672566388187 178 bytes Late, and won't win anything ... but I'm trying out how Ceylon works. An one-liner now: shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b=""";print(t+q+t+q+";value b="+q+b+q+b);}""";print(t+q+t+q+";value b="+q+b+q+b);}  The ungolfed original (1647 bytes): shared void quine69() { void printQuoted(String line) => print(" \"" + line + "\""); void printQuotedWithComma(String* seq) { for (line in seq) { print(" \"" + line.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\","); } } void printLines(String* seq) { for (line in seq) { print(line); } } value top = [ "shared void quine69() {", " void printQuoted(String line) => print(\" \\\"\" + line + \"\\\"\");", " void printQuotedWithComma(String* seq) {", " for (line in seq) {", " print(\" \\\"\" + line.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\",\");", " }", " }", " void printLines(String* seq) {", " for (line in seq) {", " print(line);", " }", " }", " value top = [" ]; value bottom = [ " ];", " printLines(*top);", " printQuotedWithComma(*top.exceptLast);", " printQuoted(top.last);", " print(\" ];\");", " print(\" value bottom = [\");", " printQuotedWithComma(*bottom.exceptLast);", " printQuoted(bottom.last);", " printLines(*bottom);", "}" ]; printLines(*top); printQuotedWithComma(*top.exceptLast); printQuoted(top.last); print(" ];"); print(" value bottom = ["); printQuotedWithComma(*bottom.exceptLast); printQuoted(bottom.last); printLines(*bottom); }  The second try, mainly with shorter names, and extract the quote function (to 1165 bytes): shared void q() { String q1(String l) => " \"" + l.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\""; void pQ(String l) => print(q1(l)); void pQC(String* seq) { for (l in seq) { print(q1(l) + ","); } } void pL(String* seq) { for (l in seq) { print(l); } } value t = [ "shared void q() {", " String q1(String l) => \" \\\"\" + l.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\"\";", " void pQ(String l) => print(q1(l));", " void pQC(String* seq) { for (l in seq) { print(q1(l) + \",\"); } }", " void pL(String* seq) { for (l in seq) { print(l); } }", " value t = [" ]; value b = [ " ];", " pL(*t);", " pQC(*t.exceptLast);", " pQ(t.last);", " print(\" ];\");", " print(\" value b = [\");", " pQC(*b.exceptLast);", " pQ(b.last);", " pL(*b);", "}" ]; pL(*t); pQC(*t.exceptLast); pQ(t.last); print(" ];"); print(" value b = ["); pQC(*b.exceptLast); pQ(b.last); pL(*b); }  The third try omits the indentation (I had to change my IDE settings to turn auto-formatting off). This gets us to 885 bytes: shared void i() { String q1(String l) => "\"" + l.replace("\\", "\\\\").replace("\"".string, "\\\"") + "\""; void pQ(String l) => print(q1(l)); void pQC(String* seq) { for (l in seq) { print(q1(l) + ","); } } void pL(String* seq) { for (l in seq) { print(l); } } value t = [ "shared void i() {", "String q1(String l) => \"\\\"\" + l.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\".string, \"\\\\\\\"\") + \"\\\"\";", "void pQ(String l) => print(q1(l));", "void pQC(String* seq) { for (l in seq) { print(q1(l) + \",\"); } }", "void pL(String* seq) { for (l in seq) { print(l); } }", "value t = [" ]; value b = [ "];", "pL(*t);", "pQC(*t.exceptLast);", "pQ(t.last);", "print(\"];\");", "print(\"value b = [\");", "pQC(*b.exceptLast);", "pQ(b.last);", "pL(*b);", "}" ]; pL(*t); pQC(*t.exceptLast); pQ(t.last); print("];"); print("value b = ["); pQC(*b.exceptLast); pQ(b.last); pL(*b); }  The fourth version has also the internal spaces, and some line breaks removed, comes down to 739 bytes: shared void n(){ String q1(String l)=>"\""+l.replace("\\","\\\\").replace("\"","\\\"")+"\""; void pQ(String l)=>print(q1(l)); void pQC(String*s){for(l in s){print(q1(l)+",");}} void pL(String*s){for(l in s){print(l);}} value t=[ "shared void n(){", "String q1(String l)=>\"\\\"\"+l.replace(\"\\\\\",\"\\\\\\\\\").replace(\"\\\"\",\"\\\\\\\"\")+\"\\\"\";", "void pQ(String l)=>print(q1(l));", "void pQC(String*s){for(l in s){print(q1(l)+\",\");}}", "void pL(String*s){for(l in s){print(l);}}", "value t=[" ];value b=[ "];", "pL(*t);pQC(*t.exceptLast);pQ(t.last);", "print(\"];value b=[\");", "pQC(*b.exceptLast);pQ(b.last);pL(*b);", "}" ]; pL(*t);pQC(*t.exceptLast);pQ(t.last); print("];value b=["); pQC(*b.exceptLast);pQ(b.last);pL(*b); }  For the next version I tried a different approach, to avoid all this escaping. Ceylon has (like Python) a "long string literal" format – everything between """ and """ is part of a string, with no escapes. ... But the indentation is removed, and because the """ itself is already 3 chars long, we also need at least those the spaces of indentation. For printing this string literal we also need to add those indentation back, and we need to handle the first and last line specially (the first needs to have """ in front, the last one is better omitted, otherwise we get one line more in the output than we already had. This (and replacing some identifiers by one-letter ones) gets us down to 672 bytes: shared void e(){ value _=" ";value q="\"\"\""; void r(String? l)=>print(q+(l else"")); void s(String l)=>print(_+q+l); void c(String*s){for(l in s){print(_+l);}} value t= """shared void e(){ value _=" ";value q="\"\"\""; void r(String? l)=>print(q+(l else"")); void s(String l)=>print(_+q+l); void c(String*s){for(l in s){print(_+l);}} value t= """;value b= """print(t);r(t.lines.first);c(*t.lines.rest.exceptLast); s(";value b="); r(b.lines.first);c(*b.lines.rest.exceptLast);s(";");print(b); } """; print(t);r(t.lines.first);c(*t.lines.rest.exceptLast); s(";value b="); r(b.lines.first);c(*b.lines.rest.exceptLast);s(";");print(b); }  (This has an empty trailing line, which Stack Exchange doesn't show. Same for the next ones.) By inlining the two short functions r and s (their savings are less than the function definition), and extracting the long .lines.rest.exceptLast expression into the c function, we get down to 566 bytes: shared void e(){ value _=" ";value q="\"\"\""; void c(String s){for(l in s.lines.rest.exceptLast){print(_+l);}} value t= """shared void e(){ value _=" ";value q="\"\"\""; void c(String s){for(l in s.lines.rest.exceptLast){print(_+l);}} value t= """;value b= """print(t);print(q+(t.lines.first else""));c(t); print(_+q+";value b="); print(q+(b.lines.first else""));c(b);print(_+q+";");print(b); } """; print(t);print(q+(t.lines.first else""));c(t); print(_+q+";value b="); print(q+(b.lines.first else""));c(b);print(_+q+";");print(b); }  Another, now "obvious" optimization would be to remove the line breaks (and most of the indentation) inside our long string literals here. By that, we actually only the first and last line of each to handle (first is to be printed with """, and the empty last one we print manually with the stuff behind it), and can get rid of the long c function which looped over everything but first and last line. This gets us down to 388: shared void e(){value _=" ";value q="\"\"\"";value t= """shared void e(){value _=" ";value q="\"\"\"";value t= """;value b= """print(t);print(q+(t.lines.first else""));print(_+q+";value b=");print(q+(b.lines.first else""));print(_+q+";");print(b);} """; print(t);print(q+(t.lines.first else""));print(_+q+";value b=");print(q+(b.lines.first else""));print(_+q+";");print(b);}  Now we can ask: why do we have many print statements, instead of using just one and some string concatenation? This gets rid of the remaining line breaks (and also the trailing empty line), and gets us down to 185 bytes (including the new line character at the end): shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b="""print(t+q+t+q+";value b="+q+b+q+";"+b);}""";print(t+q+t+q+";value b="+q+b+q+";"+b);}  Here slightly easier to read (but without syntax highlighting): shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b="""print(t+q+t+q+";value b="+q+b+q+";"+b);}""";print(t+q+t+q+";value b="+q+b+q+";"+b);} We can actually remove another 9 characters by putting this single ; inside the b string: shared void e(){value q="\"\"\"";value t="""shared void e(){value q="\"\"\"";value t=""";value b=""";print(t+q+t+q+";value b="+q+b+q+b);}""";print(t+q+t+q+";value b="+q+b+q+b);} I don't see how this could be shrunk further anymore ... maybe with a totally different approach. (I did put a commented version of this into my new Github repository). As a bonus, an "ungolfed version" of the last one (463 chars): shared void quine(){ value quote = "\"\"\""; value top = """shared void quine(){# value quote = "\"\"\"";# value top = """; value bottom = """ print(top.replace("#","\n") + quote + top + quote + ";\n value bottom = " + quote + bottom + quote + ";\n" + bottom.replace(""+"","\n"));$$}"""; print(top.replace("#","\n") + quote + top + quote + ";\n value bottom = " + quote + bottom + quote + ";\n" + bottom.replace("$"+"$","\n")); }  This needed some additional tricks to encode the line breaks in each of the string literals, because once they should be printed directly, once not. In top, I use # as a replacement. In bottom, where I replace the # in top by a newline, we need to use a different replacement string. I chose the two letter-string $$, because that can be escaped by string concatenation. • Dang! This is crazy! +1 – kirbyfan64sos Sep 14 '15 at 21:13 # Threead, 85 bytes >93>60>111>99>91>60>93>62>111>100>111>99>50>54>105>91>62>93>60>91[<]>[i62codo>]<[co<]  Try it online! >93>60>...60>91 # Encodes the second part backwards [<]> # Go back to the begining [ ] # for every number i # insert an extra cell 62co # print a '>' d # delete the cell o # print the original number in this cell > # go to the next cell <[ <] # for every cell in reverse order co # print the character that it represents  • That's really cool. Explanation to come? – Pavel Jan 13 '17 at 0:28 • @Pavel Working on it now :) – Riley Jan 13 '17 at 0:28 • That's, actually much more simple than the solution I had planned. – ATaco Jan 13 '17 at 0:33 # Shakespeare Programming Language, 6060001 bytes Disclaimer: I do not take credit for this, the generator was made by Florian Pommerening and Thomas Mayer. An Epic Never-Ending Saga. Paris, a stacky person. Pinch, impersonates Paris. Venus, the opposite of Paris and Pinch. Puck, continuously speaking. Ajax, constantly complaining. Page, perpetually blabbing. Ford, incessantly talking. Viola, ceaselessly communicating. Act I: Prelude. Scene I: Best things last. [Enter Venus and Paris] Paris: Let us proceed to act V. Act II: Remembrance. Scene I: Forgetful Venus. Paris: Remember nothing. [...]  Generator Link Generated SPL Code Translated C Code (requires spl.h and libspl.a from a bugfixed SPL version to compile) Compiled binary • This answer should be marked as community wiki, perhaps? – SuperJedi224 Dec 10 '16 at 23:12 • @SuperJedi224 Done. Thank you. – Oliver Ni Dec 11 '16 at 4:37 • @SuperJedi224 Community wiki is not a rep waiver. – Dennis Dec 16 '16 at 4:45 • Holy crap. ---- – MD XF May 24 '17 at 23:37 • also this is hardly golfed – Destructible Lemon Jun 8 '17 at 2:13 # HTML + CSS 11878777553 51 50 characters <style>*{display:flex}html:before{content:'<style>  This language isn't good for quining, but it works. Invalid HTML and CSS, but it doesn't really matter. • } isn't required – xem Dec 21 '13 at 19:02 • @xem: Removed '}. This abuses CSS error handling rules, but considering it's code golf, it's fine. – Konrad Borowski Dec 21 '13 at 19:13 • What browser did this work in? Running in Chrome 59 and this outputs *{display:inline;font-family:monospace}style:before{content:'<style> – Patrick Roberts Jul 16 '17 at 5:25 • Why does it need to be monospaced? And if it does, using <pre> is faster. – RamenChef Oct 27 '17 at 3:00 • <style>*{display:inline}style:before{content:'<style> works for less bytes. – Rɪᴋᴇʀ Feb 20 '18 at 15:30 # Haskell, 44 41 bytes EDIT: • -3 bytes due to H.PWiz GHC 8.4.1 is out, which implements the second phase of the Semigroup Monoid Proposal. As a result, the <> operator is now available without an import, which allows a 9 bytes shorter quine than the previous record, the nearly six year old answer by AardvarkSoup. main=putStr<>print$"main=putStr<>print$"  Try it online! (This cheats and has an import in the header because TIO hasn't upgraded to GHC 8.4 yet.) # How it works • <> is Semigroup multiplication, defined differently for each type it supports. • For functions, it returns a new function that takes an argument, passes it to the two multiplied functions, and then applies <> for the result type to the results. • For IO actions, it returns a new IO action that runs the two multiplied actions, and then applies <> to their result values to get the result value of the combination. • Thus putStr<>print$q = do x <- putStr q; y <- print q; pure (x<>y), which first outputs the string q, then outputs its string literal version with a newline appended. (The result values are both (), so the final one is also (), although this doesn't affect output.)
• I don't fully understand new stuff. would this be valid? – H.PWiz Apr 2 '18 at 2:24
• I figured that if Semigroup was a suprclass of Monoid, then IO () would have to become a Semigroup and <> would work – H.PWiz Apr 2 '18 at 3:14
• Oh I completely misread what you were asking. I didn't know IO () was a Semigroup. – Ørjan Johansen Apr 2 '18 at 3:15
• I don't think it is at the moment, so I would have to install the latest version to really check – H.PWiz Apr 2 '18 at 3:17
• I just installed it, my link is valid for 41 bytes :) – H.PWiz Apr 2 '18 at 3:25

# Shakespeare Programming Language, 327718 292629 bytes

That's about 286 KiB, not 3 MiB.

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

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

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

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

exit ''
eof

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

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

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

wc -c quine.spl.out

diff quine.spl quine.spl.out


Try it online!

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

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


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

The constant generation part needs a lot more work.

Each byte in the source code is encoded by:

REMEMBER <repr(value - 31)>.


where:

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


with integral x.

# A Classic - Lisp - 78

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


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

• Actually this code returns itself instead of printing itself. Running it in an interpreter with read-eval-print loop will of course print the returned list, but the printing is not part of the code itself. The C equivalent of this would be a C code which outputs its executable instead of its source code. Which would certainly also be a quite interesting problem, although heavily system-dependent. – celtschk Feb 3 '12 at 16:13
• that would make it not different from one of those function quines – Destructible Lemon Jun 24 '17 at 8:52
• the link is dead – Def Jan 15 '18 at 21:02

## PHP - 54 characters (no cheating)

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


(finally even shorter)

# Java 6 - 138 110 106

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

enum Q{X;{String s="enum Q{X;{String s=%c%s%1$c;System.out.printf(s,34,s);}}";System.out.printf(s,34,s);}}  With credits to Trixie Wolf and Volune. Note: you need to ignore stderr (e.g. 2>/dev/null) For great good (and justice)! • I can't get this to work. Did you actually try to compile it? I think you need a System.exit() gimmick or it will fail to run properly. I'll add an answer here with my implementation later if I don't hear back from you soon. – Trixie Wolf Aug 16 '14 at 4:00 • Actually: given the "ignore stderr" comment obv. you did get it to work. I'm very curious how, though. – Trixie Wolf Aug 16 '14 at 4:19 • @TrixieWolf It works fine here, there is absolutely no compile error. Did you think I would post it without trying it first? :p Anyway, you can only run it with java 6 (or 5), newer versions check for the main method first. – aditsu Aug 16 '14 at 7:52 • I'd like to suggest this improvement: enum Q{X;{String s="enum Q{X;{String s=%c%s%1$c;System.out.printf(s,34,s);}}";System.out.printf(s,34,s);}} – Volune Aug 17 '14 at 11:47
• @aditsu Ah, that makes perfect sense. I'm busy today, but tomorrow I will check to see if mine still functions correctly (I tested it recently but I'll bet it was on J6). It might still work due to the exit() trick. – Trixie Wolf Aug 17 '14 at 21:35

# MUMPS, 9 bytes

R w $T(R)  This may fall afoul of the "you can't just read the source file and print it" restriction. Let me explain why I say may. The line of code you see above constitutes a complete MUMPS "routine" (named R), which is sort of like a single source file in a conventional C-like language... but not quite. The way MUMPS stores its routines is peculiar among programming languages. Routines are not files living in a regular filesystem. Instead, they are data structures internal to the database itself. The line of code I've supplied above is actually stored as part of the MUMPS global named ^ROUTINE (globals are basically trees). The "R" subtree (in MUMPS parlance, "subscript") of that global would look something like this: ^ROUTINE("R",0)=1 ^ROUTINE("R",1)="R w$T(R)"


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

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

The ability to manipulate routines in MUMPS code is so important that the standard even defines a function whose explicit purpose is to tell you what code is found at a given line of a given routine. That function is named $T[EXT], and if you give it a pointer to a line of code, it will return the code present at that location. And that's what we do here. We w[rite] the result of a call to $TEXT(R) - that is, the contents of the line at the first line of the routine R - to the output stream, and since R is only one line long, that makes the program a quine.

This program involves no file IO at all. The whole thing is internal to the MUMPS environment. I claim that this is interesting enough to count as a legitimate quine, despite the fact that this has a surface-level resemblance to a program that just reads and prints the source file.

## Bash, 3528 20 bytes

trap -- 'trap' EXIT


@Dennis pointed out that even the -p flag is not necessary, and trap will print the trap strings unqualified, which helped save another 8 bytes, and brought about another quine:

## Zsh, 18 bytes

trap -- trap EXIT


Zsh trap does not print the single quotes, which makes it incompatible with the bash version, but also allows you to save another 2 bytes for the zsh-only version. Again, though, dash does not show this behavior and trap does not print anything.

## Bash, 19 bytes

Another, just barely shorter, and much less interesting bash quine:

echo $BASH_COMMAND  Thankfully the lack of single quotes mean that in zsh, trap is still shorter, which is important because the$BASH_COMMAND variable does not exist. Additionally, I'd be tempted to count this as 'reading the source' but that might be because I like the trap one so much.

## Bash 28 byte submission

trap -- 'trap -p EXIT' EXIT


Just realized that the echo statement could be cut out entirely, trap -p simply prints the trap statement in this format (saved another 7 bytes).

Compatibility: This must be in a script file, trap does not work as expected on the command line, and its bash-only: bourne shell/ash/dash does not support the -p flag to trap (obviously instrumental to the quine).

# Original 35 byte submission:

trap -- 'echo trap -p EXIT' EXIT


A much farther golf of @ormaaj's trap-based solution. Shaves off 1 character by switching to backticks, 2 more because the quotes around the echo body are not necessary, and 9 characters by switching to echo. The real magic though, is switching from a DEBUG trap to EXIT. This saves 2 characters just because EXIT is shorter, and 3 more because you do not need to call : or print it (and it drastically simplified the escaping needed for echo).

I'm not 100% sure whether this counts as 34 or 35 bytes, as echo prints a trailing newline and I'm not sure whether its a true quine if I don't include a trailing newline in the source. I called it 35 bytes to be more safe/truthful, but I'd love to know what a real ruling on this is.

Link to @ormaaj's original solution. (If I had enough reputation to post these golfs as a comment on the original post, I would have. My apologies if any of this breaks convention.)

• Welcome to Programming Puzzles & Code Golf, and congrats on a really neat quine! 1. trap -- 'trap' EXIT should work as well. 2. The trailing newline has to be counted, since the program wouldn't be a quine without it. 3. Your solution is different enough to be posted in a separate answer. No worries. – Dennis Oct 17 '16 at 20:24
• What was the original answer? – CalculatorFeline Jan 28 '17 at 2:13
• My original answer is the 35 byte one at the end of this post, with trap and echo. As I edited it and golfed my solution down farther, I added new solutions and comments to the top of the post. – LinusKrom Jan 29 '17 at 4:15

# 05AB1E, 14 bytes

Shortest proper 05AB1E quine?

0"D34çý"D34çý


With trailing newline.

Try it online!

Explanation:

0              # Push '0'
# Stack: ['0']
"D34çý"       # Push 'D34çý'
# Stack: ['0', 'D34çý']
D      # Duplicate
# Stack: ['0', 'D34çý', 'D34çý']
34ç   # Push '"'
# Stack: ['0', 'D34çý', 'D34çý', '"']
ý  # Join rest of the stack with '"'
# Stack: ['0"D34çý"D34çý']
# Implicit print

• Isn't 1 also a proper quine? – ovs Jan 15 '17 at 19:24
• @ovs Not by our standard definition. – ETHproductions Jan 25 '17 at 16:37

# Japt, 10 bytes

"iQ ²"iQ ²


Here's how this works:

"iQ ²"      // Take this string.        iQ ²
iQ    // Insert a quote.          "iQ ²
²  // Double.                  "iQ ²"iQ ²
// Implicitly output.


Test it online!

Of course, any number literal is also a quine because of implicit output.

• Does Japt add a newline at the end of implicit output? – CalculatorFeline Mar 23 '16 at 4:28
• @CalculatorFeline Nope. – ETHproductions Sep 7 '16 at 2:24

# Mini-Flak, 6900 bytes

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

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

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

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


## Explanation

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

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


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

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

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


Try it Online!

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

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

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


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

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

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

## Verification

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

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

Try it Online!

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

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

# 106656 bytes

Now for my fast version.

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

Try it online

## Explanation

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

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

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


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

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

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

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


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

### 4

Section 4 is a simple set up section.

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

### 3

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

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


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

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


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

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


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

### 2

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

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

### 1

Section one is the most simple section.

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

### 5

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

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

• Wait... so the quine of a subset is shorter than the quine of the original? – ETHproductions Dec 8 '16 at 23:52
• @ETHproductions No, the original was golfed down to 11k – DJMcMayhem Dec 9 '16 at 0:14
• @DJMcMayhem But isn't 6900 less than 11028? – ETHproductions Dec 9 '16 at 0:15
• ... Apparently I can't math... – DJMcMayhem Dec 9 '16 at 0:16

# Forte, 66 bytes

Updated for the new Interpreter

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


Which, in order is:

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


Try it online!

• I remember when you and me were trying to do this. I am still impressed – Christopher Apr 2 '17 at 22:07
• Why the bounty? – MD XF May 24 '17 at 23:38
• @MDXF Bounty was for writing a Forte quine, which at the time, hadn't been done. – ATaco May 24 '17 at 23:50
• @ATaco Ah, got it. Cheers – MD XF May 24 '17 at 23:51