Generate a Markdown Template for your Post

19

1

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.

Esolanging Fruit

Posted 2016-11-06T22:12:44.120

Reputation: 13 542

3I'm pretty sure this is a dup, but can't find the old one... – Dada – 2016-11-06T22:14:30.160

Related – Adnan – 2016-11-06T22:20:17.213

1I'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. – Esolanging Fruit – 2016-11-06T22:23:27.170

Should we assume standard quine rules (e.g. no opening your own code and reading it)? – Gabriel Benamy – 2016-11-06T22:32:45.690

@GabrielBenamy Yes. – Esolanging Fruit – 2016-11-06T22:49:32.333

Strange, I had this idea like two days ago... – Oliver Ni – 2016-11-07T00:08:43.270

This is definitely a duplicate as I remember: Pyke, 0 bytes. Click the copy answer button on the website – Blue – 2016-11-07T00:10:28.250

@muddyfish I searched that on Google. Was it this one?

– Esolanging Fruit – 2016-11-07T01:20:04.617

@muddyfish this has been posted in TNB as a chat mini challenge a couple times, it could have been that. – Rɪᴋᴇʀ – 2016-11-07T02:56:32.453

Answers

8

RProgN 2, 28 Bytes

«"  %s"F"#RProgN 2, 28 Bytes"

ATaco

Posted 2016-11-06T22:12:44.120

Reputation: 7 898

2As is, this isn't a serious contender and subject to deletion. Please golf your answer. – Dennis – 2017-07-05T17:32:38.007

1@Dennis Golfed. – ATaco – 2017-07-05T20:56:23.663

2Nice! The dot after the byte count doesn't seem to be required, but there should be four spaces (or a tab) before the code. – Dennis – 2017-07-05T21:09:49.887

5

Underload, 48 bytes

(#Underload, 48 bytes
)(~:S(    ):S*aSaS(:^)S):^

user62131

Posted 2016-11-06T22:12:44.120

Reputation:

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). – None – 2016-11-12T12:35:47.887

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. – None – 2016-12-02T23:23:57.760

2You can discuss in Underload quines? (Cool!:aSS)Cool!:aSS – CalculatorFeline – 2017-06-21T21:23:06.193

1@CalculatorFeline Unfortunately, that doesn't work because of the (!). – Esolanging Fruit – 2017-11-28T03:30:28.773

2

Python 2, 58 bytes

_='## Python 2, 58 bytes\n    _=%r;print _%%_';print _%_

Erik the Outgolfer

Posted 2016-11-06T22:12:44.120

Reputation: 38 134

The contents of this post are exactly as printed by the code. – Erik the Outgolfer – 2016-11-08T13:00:37.577

1

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>

Esolanging Fruit

Posted 2016-11-06T22:12:44.120

Reputation: 13 542

1

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

Shaggy

Posted 2016-11-06T22:12:44.120

Reputation: 24 623

1

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

James

Posted 2016-11-06T22:12:44.120

Reputation: 54 537

1

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.

Conor O'Brien

Posted 2016-11-06T22:12:44.120

Reputation: 36 228