19
A metaquine is a program which is not a quine, but whose output, when run as a program in the same language, is a quine.
The goal of this challenge is to write a metaquine. This is code-golf, so shortest code wins, with earliest answer used as a tiebreaker. Note that only full programs are acceptable, due to the definition of a quine.
Rules for Quines
Only true quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, without:
- reading your source code, directly or indirectly.
- relying on a REPL environment which just simply evaluates and prints every expression you feed it.
- relying on language features which just print out the source in certain cases.
- using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)
- the source code consisting purely of literals (whether they be string literals, numeric literals, etc.) and/or NOPs.
Any non-suppressible output (such as copyright notices, startup/shutdown messages, or a trailing line feed) may be ignored in the output for the sake of the validity of the quine.
Example
Ignoring the rule which forbids literal-only programs and built-in quining, this would be a metaquine in Seriously:
"Q"
The program consists of the single string literal "Q"
, which is implicitly printed at output. When the output (Q
) is run, it is a quine (Q
is the built-in quine function).
2Does the literals/comments/NOPs rule apply to the output (i.e. the real quine) of the metaquote as well? Otherwise ex.
T
is an easy 1-byte Pyth answer. – Doorknob – 2016-02-12T18:23:45.207@Doorknob Yes, I'll clarify. – Mego – 2016-02-12T18:25:42.507
8I don't really see where's the difficult point of this challenge. Isn't the strategy "print the string which contains the shortest known quine" pretty much guaranteed to win for each language? – Fatalize – 2016-02-12T18:30:25.773
1@Fatalize Well I guess the interesting question is, can that be done in the same amount or fewer bytes than the quine itself. – Martin Ender – 2016-02-12T18:53:51.160
3@Fatalize Isn't it also possible that you could write a short metaquine that prints a long but valid quine? – Rhyzomatic – 2016-02-12T19:25:18.163
You should add a rule to prevent the empty quine. E.g. any C program which produces no output technically could be a meta-quine, because a blank source code will compile (and print nothing, which happens to be its source code). – Darrel Hoffman – 2016-02-12T22:58:23.637
@DarrelHoffman Empty programs are already a standard loophole – Mego – 2016-02-12T23:35:43.533
What kind of a quine gives shutdown messages? o_O – Conor O'Brien – 2016-02-13T00:59:40.967
@CᴏɴᴏʀO'Bʀɪᴇɴ I'd imagine some interpreter out there always prints "Goodbye!" or something similarly ridiculous on exit. – Mego – 2016-02-13T01:03:37.213
Oh, program shutdown messages. I thought you meant computer shutdown messages ^^" – Conor O'Brien – 2016-02-13T01:04:13.330
@CᴏɴᴏʀO'Bʀɪᴇɴ Well it really depends on your definition of interpreter. It could be a literal OS shutdown message with C/assembly, where the "interpreter" is the processor. – Mego – 2016-02-13T01:05:11.093
So... is SMBF allowed, since the source code and execution happen on the same tape? Example quine (not metaquine):
– mbomb007 – 2016-02-13T03:19:12.287<[<]>[.>]
, which does use its own code that was on the tape (and can be read/modified) during execution. I guess I'll post an answer, and people can downvote if they don't like it.