245
\$\begingroup\$

Using your language of choice, golf a quine.

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

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

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

Points for:

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

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

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}
function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.has_more)more_answers=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
getAnswers();var SCORE_REG=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery('<i>'+a.language+'</i>').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654"> <div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> 

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

455 Answers 455

1
\$\begingroup\$

Agony, 243 bytes

<[.<]>[{(<(<){*}*{(>)}~)<(<){-.+(*}*<{)>(>)>}]${(@]@){,{.{[{*{]{)+*<}>[>*+)+]{@$${<{<<$+(@[{({.{({,>]@(>]+[>){,{({.+(@[+({,+(@(+({]+({)+({.<$@[<${-+({<@[+[>]{.>]{->]{.+(>){,+[{,{-{({]{[+({.>){->){.+]+[{.>]{-+({,+[{,+({.>){->){-+(@(>]@[>){]@(>)

Try it online!

This looks like a bit of a mess, but this language is actually a brainfuck derivative, similar to SMBF. The self-modifying part is not used to read the executed code though (especially as each instruction is not mapped to one character). Agony splits up each brainfuck cell into 4 bits each (with two cells being a "character"), with special instructions to manipulate individual cells.

Explanation:

The code is split up into three sections; Code, the printable list of characters (offset by one to avoid the zero cell in @) and the data section (which is the printable version of the other two sections backwards).

Code

<[.<]      Print out the data section printing the code and the list of chars
>[         Loop over each 4 bits of the data section
  {(         While the current cell is not zero
    <(<){      Go to the start of the character list
    *}*{       Move it over one cell to make the next character the new start
    (>)}~      Go back to the current cell and decrement it
  )
  <(<){      Go to the start of the character list
  -.+        Print it offset by one (`@` is 0010 0000, so we store it as 0010 0001)
  (*}*<{)    Move over all the other characters by one to restore the list
  >(>)>}     Move to the next cell in the data section
]$         End the loop and halt

This section is modified or read (except the $, which separates it from the character list section).

Character list

The character list is the section between the $ and the $$

{( @] @) {, {. {[ {* {] {) +* <} >[ >* +) +] {@
$  }  {  >  <  @  ~  +  -  .  ,  (  )  [  ]  *

Each pair of characters represents 8 bits each, which is the ordered list of the 15 instructions in Agony (offset by one).

Data section

Similar to the character section, each pair of characters in this part represent a single character in the code section. You can have it more efficient by just duplicating the code section entirely (thus being one to one), which is actually how the reference quine works. However, I think that even golfed, this would still take more code to handle duplicating the data section than it would save (but I'm not too sure about that, so feel free to prove me wrong).

\$\endgroup\$
1
\$\begingroup\$

ALGOL 68 (Genie), 70 bytes

STRINGa="STRINGa="";print(a[..9]*2+a[9..]*2)";print(a[..9]*2+a[9..]*2)

Try it online!

It's fascinating how modern feeling the syntax of this language (or at least the parts I've used), despite being over 50 years old. I wrote this without looking at any documentation, simply guessing at the features like string indexing (with ranges even!) and string multiplying.

Explanation:

STRINGa="STRINGa="";print(a[..9]*2+a[9..]*2)";  # Assign this string to `a` #
                                                # This escapes the " by doubling it #
print(a[..9]*2             # Print STRINGa=" twice #
     +a[9..]*2)            # Followed by ";print(a[..9]*2+a[9..]*2) twice #
\$\endgroup\$
1
\$\begingroup\$

tinylisp, 2 bytes

Very simple quine, and (one of) the shortest possible quine(s) in tinylisp. All top-level statements implicitly output whatever they evaluate to, and integers evaluate to themselves. Any 1-digit integer from 0 to 9 works fine for this, and a 3-byte quine is also possible using ().

1

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Knight (v2.0-alpha), 35 bytes

O S=s"O S=s5F++A34sA34"5F++A34sA34

Try it online!

Expanded:

OUTPUT SET
    : = s "O S=s5F++A34sA34"
    : 5
    : F
    : ++ ASCII 34 s ASCII 34
\$\endgroup\$
1
\$\begingroup\$

Javascript 6 Characters 13 Characters

Working Version

f=_=>`f=${f}`

Previous Bad Version

f=_=>f

This quine is only 13 characters long

This code defines an anonymous function that outputs its own source code to the console when it is called. The source code of the anonymous function is defined as a string inside the function, and this string is used to output the source code of the anonymous function when it is called. This means that the code outputs its own source code, but it does not just read its own source code directly.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I think this would be considered invalid for a few reasons. First, its output isn't a string, and even if it was turned into a string, it would be _=>f without the f=). Second, it reads its own source code, if implicitly. \$\endgroup\$ Dec 5, 2022 at 19:59
  • \$\begingroup\$ @RadvylfPrograms I've updated it with one that actually meets the requirements for slightly more characters but still smaller than the versions I have found on here I think \$\endgroup\$
    – Shubshub
    Dec 5, 2022 at 22:45
  • \$\begingroup\$ "f="+f is shorter than a template string containing f=${f}, but then you've just got the classic JS cheating quine, f=_=>"f="+f \$\endgroup\$ Dec 6, 2022 at 14:19
  • \$\begingroup\$ Y'all downvoting yet this one with 51 upvotes also reads its own source codegolf.stackexchange.com/a/60148/53343 \$\endgroup\$
    – Shubshub
    Dec 6, 2022 at 21:03
  • 1
    \$\begingroup\$ That was 7 years ago though, our standards have changed a bit. \$\endgroup\$ Dec 6, 2022 at 21:06
1
\$\begingroup\$

SQL - Snowflake, 26 bytes

Using CURRENT_STATMENT function:

Returns the SQL text of the statement that is currently executing.

SELECT CURRENT_STATEMENT()

Output:

SELECT CURRENT_STATEMENT()
\$\endgroup\$
1
\$\begingroup\$

Thunno KJ, \$ 16 \log_{256}(96) \approx \$ 13.17 bytes

"D34CDZs"D34CDZs

Attempt This Online!

Sort of like lyxal's Thunno answer, but uses flags and the stack instead of the x variable.

Explanation

"D34CDZs"D34CDZs  #                                    STACK:
"D34CDZs"         # Push the string to the stack       D34CDZs
         D        # Duplicate this string              D34CDZs, D34CDZs
          34C     # Push chr(34), the double quote     ", D34CDZs, D34CDZs
             D    # Duplicate this string              ", ", D34CDZs, D34CDZs
              Zs  # Swap the second and third items    ", D34CDZs, ", D34CDZs
                  # The flags join the stack           "D34CDZs"D34CDZs
                  # Implicit output
\$\endgroup\$
1
\$\begingroup\$

ReRegex, 117 bytes

_()9(?=.*\/)/\//_()8(?=.*\/)/\\/^\/(.*)/$1\/$1/\/_()9(?=.*_8_9)_9_8_9_9_()8(?=.*_8_9)_9_8_8_9^_8_9(.*)_9$1_8_9$1_9_8

As with many quines, works by unpacking and decoding the data. The data is _()9(?=.*_8_9)_9_8_9_9_()8(?=.*_8_9)_9_8_8_9^_8_9(.*)_9$1_8_9$1_9_8 (Everything after the last regex), and the decoding is done via 3 regexes.

_()9(?=.*\/)/\//    # Replace instances of _9 with /
_()8(?=.*\/)/\\/    # Replace instances of _8 with \
^\/(.*)/$1\/$1/\/   # If the data starts with a /, copy everything behind it.

_()s are included in the first half of the number regex to ensure they aren't replaced when they represent the regexes themselves. (?=.*\/) asserts that it only replaces numbers behind a /.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Shasta v0.0.9, 67 bytes

q='"'a="q='%s'a=%s(printf a[q,(wrap a q)])"(printf a[q,(wrap a q)])

There is no online interpreter for Shasta yet, but there are installation instructions at the GitHub link and I have verified that this works on my machine.

There is likely a much shorter quine possible, but I'm new to writing these.

\$\endgroup\$
1
\$\begingroup\$

ARM Thumb machine code + Linux syscalls, 14 bytes (non-competing)

Hexdump of source:

0210 2ffa 1040 22e0 7240 fd00 7407

Disassembly:

00: 2001       movs r0, #1      // stdout
02: f2af 0104  subw r1, pc, #4  // address of start
06: 220e       movs r2, #14     // 14 bytes
08: 2704       movs r7, #4      // write()
0a: df00       svc  #0          // syscall
0c: 4770       bx   lr          // return

Is this against the rules?

\$\endgroup\$
2
  • \$\begingroup\$ I would say that this would count as reading your own source code, yes \$\endgroup\$
    – Jo King
    Jun 25, 2023 at 3:43
  • \$\begingroup\$ ok should i delete this then? \$\endgroup\$ Jun 25, 2023 at 9:08
1
\$\begingroup\$

Emacs Lisp, 23 bytes

(insert(buffer-string))

Execute it with C-x C-e. The normal C-j key binding runs it in debug mode, so the nil return value of insert will also get printed afterwards. (Also, if an error appears, make sure the cursor is at the end of the buffer.)


Explanation

Emacs uses buffers to edit, read or write text/code. By default, the current buffer is used for most operations. To get the contents of the current buffer, we can use buffer-string. We can then insert the contents back into the buffer using the handy-dandy function insert.

Output

On the first execution, it sets the buffer to:

(insert(buffer-string))(insert(buffer-string))

Since C-x C-e only executes the last S-expression, running the program again will copy its contents:

(insert(buffer-string))(insert(buffer-string))(insert(buffer-string))(insert(buffer-string))

Have a fantastic week!

\$\endgroup\$
1
\$\begingroup\$

Bash, 18 Bytes

history|tail -c18

Bytes:

echo 'history|tail -c18' > quine
wc -c quine
18 quine

Explanation:

history gets the bash history from memory and tail grabs the last 18 characters.

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Welcome to Code Golf! Unfortunately, since this solution reads its own source code, it's not a valid quine on this site (see the rules of this challenge) \$\endgroup\$
    – noodle man
    Nov 27, 2023 at 23:55
1
\$\begingroup\$

TypeScript's Type System, 115 bytes

type Y="'";type A='type O=`type Y="${Y}";type A=${Y}${A}${Y};${A}`';type O=`type Y="${Y}";type A=${Y}${A}${Y};${A}`

Try it at the TS playground

This beats tjjfvi's 149 byte quine.

\$\endgroup\$
1
\$\begingroup\$

Vyxal 3, 4 bytes

"Ṅ"Ṅ

Try it Online!

new name same old quine element

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

CJam, 1 byte

Note: CJam was made after this challenge was posted, I am posting this answer as documentation as opposed to a serious entry.

0

Pushes a 0 to the stack, and CJam automatically outputs the stack after program execution.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Don't forget newlines. \$\endgroup\$ May 28, 2017 at 1:39
  • 3
    \$\begingroup\$ One part of the program does not encode another, so this program is invalid \$\endgroup\$
    – MilkyWay90
    Feb 5, 2019 at 18:04
  • \$\begingroup\$ @MilkyWay90 Am I missing something about the definition of a quine? The challenge simply states "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." This seems to do that. \$\endgroup\$ Mar 31, 2021 at 18:15
  • \$\begingroup\$ @MilkyWay90 the rule is it has to evaluate its code, not that it has to encode its code. \$\endgroup\$
    – Dadsdy
    Jul 18, 2023 at 8:32
0
\$\begingroup\$

ForceLang with this module, 87 bytes

Noncompeting, language postdates the challenge

set j require njs
j var f=function(){print("set j require njs\nj var f="+f+";f()")};f()
\$\endgroup\$
0
\$\begingroup\$

Idris, 88 bytes

q:String;main:IO();main=putStr$q++show q;q="q:String;main:IO();main=putStr$q++show q;q="

It’s like Haskell with more enforced top-level type signatures. I had to put q’s type first, because Idris’s type checker is a little weird? I dunno.

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

Pyke, 14 bytes

"34.Cp\D\Es"DE

Try it here!

"34.Cp\D\Es"   - "34.Cp\D\Es"
            DE - eval(^, stack=^)

 34.C          -   '"'
     p         -  print(^)
      \D\Es    - sum("34.Cp\D\Es", ^, "D", "E")
\$\endgroup\$
0
\$\begingroup\$

SimpleTemplate, 56 bytes

This is a template engine language I've made for fun.

It was written in PHP and run by compiling the weird syntax to PHP.

This answer is a translation of Aurel Bílý's amazing PHP answer!

{@setF"{@setF%c%s%c}{@printF,34,F,34}"}{@printF,34,F,34}

Weird, right?

This works with the commit d1d3e2c43bd98da2bd38f884ee5ac7b39cb8c579 on my Github and you can try it on http://sandbox.onlinephpfunctions.com/code/cca9ed3b9c87abad61159725f159285e5daf9bb9.

In there, you will have the existing code on that commit, plus showing the result and the generated PHP.

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

R, 47 bytes

f=function(){cat('f=');print(f);cat('f()')}
f()

Try it online!

Can be extended to contain any set of operations by adding those before the first cat statement.

Printing a function f returns the content of that function starting with function(){. I then added cat statements to handle the rest of the output.

\$\endgroup\$
4
  • \$\begingroup\$ should probably be 53 bytes, as print will add indentation and weird brackets placement. \$\endgroup\$
    – Giuseppe
    Jan 25, 2018 at 15:41
  • \$\begingroup\$ @Giuseppe hmm, on TIO there also appears to be trailing spaces. If counting those we'd end up at 64 bytes \$\endgroup\$
    – JAD
    Jan 25, 2018 at 16:36
  • \$\begingroup\$ :| too long \$\endgroup\$
    – ASCII-only
    May 13, 2018 at 10:37
  • \$\begingroup\$ Alhough TIO adds spaces and newlines, my local install does not. The same thing occurs with my 44 byte answer. I haven't found which option is different between the two installs. Also, I accidentally downvoted your answer instead of upvoting it, and my vote is now locked. Sorry about that. If you edit your answer, I'll change my vote. \$\endgroup\$ Aug 4, 2020 at 15:29
0
\$\begingroup\$

GNU Make, 52 51 11 bytes

$(value $0)

When called as a function, returns its source code.

And here's a complete makefile that doesn't return its code, but rather prints it:

Q=$(info Q=$(value Q))$(info $$(call Q))
$(call Q)

Explanation

The second line just instantiates the variable, the first one defines it:

$(info Q=$(value Q))$(info $$(call Q))
         $(value Q)                     # Get unexpanded value
                           $$           # "$" escaped
$(info Q=          )$(info   (call Q))  # Print the remaining parts
\$\endgroup\$
0
\$\begingroup\$

Babel, 161 bytes

{ "{ '{ ' << dup [val 0x22 0xffffff00 ] dup <- << << -> << ' ' << << ' }' << } !" { '{ ' << dup [val 0x22 0xffffff00 ] dup <- << << -> << ' ' << << '}' << } ! }%
\$\endgroup\$
0
\$\begingroup\$

Ceylon, 173 154 bytes

Saved those bytes thanks to Challenger5

shared void run(){print(let(x="""shared void run(){print(let(x=$)x.replaceFirst("$","\"\"\""+x+"\"\"\""));}""")x.replaceFirst("$","\"\"\""+x+"\"\"\""));}

source

\$\endgroup\$
2
  • \$\begingroup\$ You can golf off some whitespace. Try it online! \$\endgroup\$ May 25, 2017 at 1:07
  • \$\begingroup\$ @Challenger5 Cheers :D \$\endgroup\$
    – MD XF
    May 25, 2017 at 1:10
0
\$\begingroup\$

ColdFusion, 276 bytes

<cfset u=Chr(34)><cfset q="<cfset u=Chr(34)><cfset q=%s%s%s><cfoutput>%screateObject(%sjava%s,%sjava.lang.String%s).format(q,[u,q,u,Chr(35),u,u,u,u,Chr(35)])%s</cfoutput>"><cfoutput>#createObject("java","java.lang.String").format(q,[u,q,u,Chr(35),u,u,u,u,Chr(35)])#</cfoutput>

I've never used ColdFusion, but after seeing @Danninta's post on Self-growing code codee codeee codeeee I thought I'd play around. This could almost certainly be golfed down by someone that actually knows the language, so feel free to add a new answer.

Tested locally on lucee-express-5.2.6.60

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

Jstx, 4 bytes

£↕26

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You might want to include an explanation, I'd be interested! Also I believe you'll need to include a newline in your code since the output of this program seems to include one as well. \$\endgroup\$ Apr 10, 2018 at 16:34
  • 1
    \$\begingroup\$ I assume you are the created of Jstx and the GitHub? In your documentation you mention all the possible commands/operations/functions, but not which character represents it. Since I couldn't find it in the documentation, what commands/operators/functions do these £ and represent? \$\endgroup\$ Apr 20, 2018 at 12:03
  • \$\begingroup\$ It's not a solid association between opcodes and bytes, and it changes from version to version of the interpreter and compiler. In fact some opcodes can actually remap every opcode to byte association at runtime. Fortunately you don't need to worry about which bytes correspond to which instructions because all the programming is done directly through instructions using the Jstx compiler, then the resulting bytes can be interpreted with the same version of the Jstx interpreter. \$\endgroup\$
    – Quantum64
    Apr 21, 2018 at 16:53
0
\$\begingroup\$

PHP, 147 bytes

<?php $c= <<<'s'
	$n='<?php $c= <<<\'s\''."\n";global $c;echo($n.$c."\ns;\n".'$e=create_function("",$c);$e();');
s;
$e=create_function("",$c);$e();

Try it online!

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

VBA, 77 bytes

An anonymous VBE immediate window quine.

c=Chr(34):q="c=Chr(34):q=:?Replace(q,Chr(7),c+q+c)":?Replace(q,Chr(7),c+q+c)
\$\endgroup\$
0
\$\begingroup\$

Runic Enchantments, 7 bytes

"'<~S@|

Try it online!

Explanation

  <        Entry
"'         Push the " character (loop around)
      |    Mirror (loop around)
"          Begin string mode
 '<~S@|    Push the string '<~S@|
"          End string mode
 '<~       Push and pop a < character
    S      Swap stack the following also work, r: reverse, q: concatenate, +: add
     @     Print and terminate
\$\endgroup\$
0
\$\begingroup\$

Tidy, 71 bytes

q:=34|chr|str;a:="q:=34|chr|str;a:=%swrite(a%%(q.a.q))"write(a%(q.a.q))

Try it online!

q:=34|chr|str gets a quote character, and a:=... defines the format string. Finally, write(a%(q.a.q)) formats a with a surrounded by quotes.

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

Tamsin, 67 bytes

main='->T&$:repr(T)->U&\'main=\'+U+T.'->T&$:repr(T)->U&'main='+U+T.

Ungolfed (isn't a quine, but outputs a quine):

main =  '→T&$:repr(T)→U&\'main=\'+U+T.' → T
     &  $:repr(T) → U
     &  'main=' + U + T.

Tamsin has a builtin that formats strings correctly, which makes this fairly easy.

\$\endgroup\$

Your Answer

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

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