21
\$\begingroup\$

Your task is simple: Write a program (or function) that takes no input and outputs something like this:

## *name*, *length* bytes
    *code*

Where *name* is the name of the language you are using, *length* is the number of bytes in your code, and *code* is your program's source code. If *code* contains multiple lines, it have four spaces before each line.

Here's a 124-byte example implementation in Python 3:

s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
print(s.format(s,chr(34),chr(10)))

The output is:

## Python 3, 124 bytes
    s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
    print(s.format(s,chr(34),chr(10)))

Which in Markdown is:

Python 3, 124 bytes

s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
print(s.format(s,chr(34),chr(10)))

This is , so the shortest answer (in bytes) wins.

\$\endgroup\$
  • 3
    \$\begingroup\$ I'm pretty sure this is a dup, but can't find the old one... \$\endgroup\$ – Dada Nov 6 '16 at 22:14
  • \$\begingroup\$ Related \$\endgroup\$ – Adnan Nov 6 '16 at 22:20
  • 1
    \$\begingroup\$ I'd say this is different enough from that one because it's generating one for itself. The idea is similar, but you need to write a quine for this one. \$\endgroup\$ – Esolanging Fruit Nov 6 '16 at 22:23
  • \$\begingroup\$ Should we assume standard quine rules (e.g. no opening your own code and reading it)? \$\endgroup\$ – Gabriel Benamy Nov 6 '16 at 22:32
  • \$\begingroup\$ @GabrielBenamy Yes. \$\endgroup\$ – Esolanging Fruit Nov 6 '16 at 22:49
8
\$\begingroup\$

RProgN 2, 28 Bytes

«"  %s"F"#RProgN 2, 28 Bytes"
| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ As is, this isn't a serious contender and subject to deletion. Please golf your answer. \$\endgroup\$ – Dennis Jul 5 '17 at 17:32
  • 1
    \$\begingroup\$ @Dennis Golfed. \$\endgroup\$ – ATaco Jul 5 '17 at 20:56
  • 2
    \$\begingroup\$ Nice! The dot after the byte count doesn't seem to be required, but there should be four spaces (or a tab) before the code. \$\endgroup\$ – Dennis Jul 5 '17 at 21:09
5
\$\begingroup\$

Underload, 48 bytes

(#Underload, 48 bytes
)(~:S(    ):S*aSaS(:^)S):^
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Post is exactly as produced by the code. The quine is payload-capable (place the payload after the final S), thus making it a true quine by one widely-used definition, but uses a string eval (that said, string eval is the only way to do a loop in Underload; it's fairly fundamental to the language). \$\endgroup\$ – user62131 Nov 12 '16 at 12:35
  • \$\begingroup\$ After a discussion in Underload quines in chat, we decided this is also a quine by the other widely-used definitions too; the :^ at the end of the program is encoded by the :^ a little earlier, and thus one part of the program encodes a different part. \$\endgroup\$ – user62131 Dec 2 '16 at 23:23
  • 2
    \$\begingroup\$ You can discuss in Underload quines? (Cool!:aSS)Cool!:aSS \$\endgroup\$ – CalculatorFeline Jun 21 '17 at 21:23
  • 1
    \$\begingroup\$ @CalculatorFeline Unfortunately, that doesn't work because of the (!). \$\endgroup\$ – Esolanging Fruit Nov 28 '17 at 3:30
2
\$\begingroup\$

Python 2, 58 bytes

_='## Python 2, 58 bytes\n    _=%r;print _%%_';print _%_
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The contents of this post are exactly as printed by the code. \$\endgroup\$ – Erik the Outgolfer Nov 8 '16 at 13:00
1
\$\begingroup\$

reticular, 58 bytes

"'34'c: 4*91+c:s:e:t:y:b: 85: :,:r:a:l:u:c:i:t:e:r: :#dqO;

Try it online!

Explanation: :c pushes the single-char string c. This builds the string "## reticular, 58 bytes", backwards character by character, reverses the stack, and Outputs everything, including the string captured by the initial quote.

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

CJam, 33 bytes

{"## CJam, 33 bytes"N@S4*\"_~"}_~

Works a lot like the Underload answer.

Stack trace (N represents \n)

{"## CJam, 33 bytes"N@S4*\"_~"}
{"## CJam, 33 bytes"N@S4*\"_~"} {"## CJam, 33 bytes"N@S4*\"_~"}
{"## CJam, 33 bytes"N@S4*\"_~"} "## CJam, 33 bytes"
{"## CJam, 33 bytes"N@S4*\"_~"} "## CJam, 33 bytes" N
"## CJam, 33 bytes" N {"## CJam, 33 bytes"N@S4*\"_~"}
"## CJam, 33 bytes" N {"## CJam, 33 bytes"N@S4*\"_~"} " "
"## CJam, 33 bytes" N {"## CJam, 33 bytes"N@S4*\"_~"} " " 4
"## CJam, 33 bytes" N {"## CJam, 33 bytes"N@S4*\"_~"} "    "
"## CJam, 33 bytes" N "    " {"## CJam, 33 bytes"N@S4*\"_~"}
"## CJam, 33 bytes" N "    " {"## CJam, 33 bytes"N@S4*\"_~"} "_~"
<implicit output>
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

V, 25 bytes

ñi#V, 25 bytes<esc>o´ Ñ<esc>~"qpx

(This is not counted in the generated markdown, because I like providing explanations for my code :P)

Here is a hexdump, since the source code contains unprintable/non-ASCII characters:

00000000: f169 2356 2c20 3235 2062 7974 6573 1b6f  .i#V, 25 bytes.o
00000010: b420 d11b 7e22 7170 78                   . ..~"qpx

This answer is just a trivial modification of the standard extensible V quine.

Explanation:

ñ                                   " Run the following code one time, storing it in
                                    " register 'q'
 i                                  "   Enter insert mode
  #V, 25 bytes<esc>                 "   And insert the header
                   o                "   Open up a newline, and enter insert mode again
                    ´ Ñ             "   Enter four spaces, then a 'Ñ' character.
                                    "   (The reason we insert it uppercase, is because
                                    "   lowercase would end the loop now)
                       <esc>        "   Return to normal mode
                            ~       "   Toggle the case of the char under the cursor ('Ñ')
                             "qp    "   Paste the contents of register 'q' (this is the
                                    "   same as the entire program minus the initial 'ñ',
                                    "   followed by a 'ÿ' character because V is weird)
                                x   "   Delete the last character (the ÿ)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

JS, 50 49 27 30 bytes

f=_=>`#JS, 30 bytes\n    f=`+f

Try It

f=_=>`#JS, 30 bytes\n    f=`+f
console.log(f())

| improve this answer | |
\$\endgroup\$

Your Answer

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

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