5
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.
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? – dylnan – 2018-04-09T21:30:04.177
@dylnan You can put it anywhere: comments, literals, variable names, as long as you handle any printable ASCII. – Nissa – 2018-04-09T21:32:45.623
3I thought the usual term was
payload
– Jo King – 2018-04-09T21:34:21.390@JoKing I got the term "intron" from this article on quines.
– Nissa – 2018-04-09T21:45:55.430Related. – Martin Ender – 2018-04-09T22:26:58.433
"My challenge is to write a quine that will normally run as a standard quine" and "The returned program need only be similar in any way to the original if it's called without arguments" condradict each other. – Shaggy – 2018-04-10T07:16:06.387