In the context of quines, an intron (or payload) is a part of a quine that serves no purpose in producing output, but is still included in the data section. For example:

function quine() {
    const data = "function quine() {\n    const data=\"@\";\n    // Arr! This be an intron!\n    return data.replace(\"@\", JSON.stringify(data));\n}";
    // Arr! This be an intron!
    return data.replace("@", JSON.stringify(data));

My challenge is to write a quine that will normally run as a standard quine, but if an argument is passed in, then it returns a new quine with the argument placed somewhere in it. If that new quine is called with an argument, it should do the same. For example:

function quine(intron="") {
    const data = "function quine(intron=\"\0\") {\n    const data = \"%%%\";\n    //\0\n    return data.replace(/\u0000/g, intron).replace(\"%%%\", JSON.stringify(data));\n}";
    return data.replace(/\u0000/g, intron).replace("%%%", JSON.stringify(data));

A few statements:

  • If you have no input, then the output should be identical to the source code. If you have input, then the output only needs to:
    • Be in the same language
    • Contain the input
    • Be a solution to this challenge in its own right
  • Quines only need to contain the latest intron. Introns from the program that generated it are optional.
  • If your program already contains the input, then the same program is fine. For example, if it's called with the same input twice.
  • The input can be assumed to be printable ASCII only.
  • The shortest program in bytes wins.
  • \$\begingroup\$ So with no argument, the program should be a quine, and with an argument the output should be a quine with the argument as a contiguous sublist somewhere in the text? \$\endgroup\$
    – dylnan
    Apr 9, 2018 at 21:30
  • \$\begingroup\$ @dylnan You can put it anywhere: comments, literals, variable names, as long as you handle any printable ASCII. \$\endgroup\$
    – Nissa
    Apr 9, 2018 at 21:32
  • 3
    \$\begingroup\$ I thought the usual term was payload \$\endgroup\$
    – Jo King
    Apr 9, 2018 at 21:34
  • \$\begingroup\$ @JoKing I got the term "intron" from this article on quines. \$\endgroup\$
    – Nissa
    Apr 9, 2018 at 21:45
  • \$\begingroup\$ Related. \$\endgroup\$ Apr 9, 2018 at 22:26

3 Answers 3


Python 2, 70 bytes

def f(x=''):s='def f(x=%r):s=%r;print s%%(x,s,x)#%s';print s%(x,s,x)#

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds an extra %s after a comment, to output the data, and a %r in the default string to push the original string as default instead of an empty string.

  • \$\begingroup\$ I don't believe this supports input containing both ' and ". \$\endgroup\$ Apr 10, 2018 at 18:05
  • \$\begingroup\$ @ØrjanJohansen Should be fixed \$\endgroup\$
    – Jo King
    Apr 11, 2018 at 0:24
  • \$\begingroup\$ I don't quite understand the purpose of the %r in the default, or of changing x in the function. Although it might be related to the question I just asked on the OP (in which case I don't think it actually works if you explicitly pass in the same string again.) \$\endgroup\$ Apr 11, 2018 at 1:19

V, 11 bytes


Try it online!


00000000: f1e9 d176 7522 7170 783a 22              ...vu"qpx:"

This is a simple modification of the standard V quine. Given the input:


this program will output:


Which outputs:


This works because the input is automatically appended to the end of ñéÑvu"qpx, and :" is a comment (essentially)

  • 1
    \$\begingroup\$ Wouldn't a " in the input break it? \$\endgroup\$
    – Jo King
    Apr 10, 2018 at 11:41
  • 1
    \$\begingroup\$ @joking Surprisingly, no. " is a line comment. \$\endgroup\$
    – DJMcMayhem
    Apr 12, 2018 at 4:50

Python 3, 77 bytes

t='';s='t=input()or t;print(f"t={repr(t)};s={repr(s)};exec(s)#{t}")';exec(s)#

Try it online!

Full programs. Input must be terminated with a newline, and output a trailing newline.

Equivalent Python 2 would be 76 bytes (I think).


Your Answer

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

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