13
This challenge is similar to Can you Meta Quine?
A quine is a program that produces itself on STDOUT. This challenge is to produce a program A which when run produces a program B on STDOUT. Program B when run produces program A on STDOUT. Programs A and B must be written in (and run in) the same language. The linked question constrained A != B. That looked too easy. So for this question, we insist A and B are antiquines, using the following rules:
- Programs A and B may not use any of the same characters, save for whitespace and statement separators, and punctuation characters.
- Programs A and B must each contain at least one character that is neither whitespace nor a statement separator, nor a punctuation character.
- For the purpose of rules 1 and 2, the term 'whitespace' excludes any symbol or sequence of symbols which itself is a statement, operator or symbol that is interpreted (as opposed to a separator). Therefore in the Whitespace language, there is no whitespace.
- A statement separator is a syntactic element conventionally used within the language to separate statements. This would include the newline in python, or the semicolon in Java, perl or C.
- A punctuation character is an ASCII character which is neither whitespace nor in the POSIX word character class (i.e. an underscore is not punctuation for this purpose) - i.e
ispunct()
would return true, and it's not_
. - Program A when run must produce a program (Program B) on its STDOUT, which when run in turn produces Program A.
- Programs A and B must be in the same programming language.
- The programming language used must actually be a programming language. Unless you make a good case otherwise, I'll suggest it must be Turing complete.
- At least one of A and B must execute at least one statement within the language.
This is code golf, so the shortest answer wins, the score being the length of program A in bytes (i.e. the length of program B is not relevant).
Can you please add "punctuation" to the list of exceptions in the first clause? It's impossible to solve this task in many languages (especially those that require you to you curly braces in the main function) otherwise. – FUZxxl – 2014-08-16T19:21:11.180
related but probably sufficiently different. – Martin Ender – 2014-08-16T19:23:12.027
@FUZxxl I've permitted punctuation marks but excluded underscores. – abligh – 2014-08-16T19:32:55.280
So just to make sure: Things like
'
and"
are allowed to appear in both programs, correct? – Ingo Bürk – 2014-08-16T20:05:34.703@IngoBürk, yes, thinks like
'
and"
can appear in both programs (per the exception at the end of rule 1). However there must be something that appears in each program that is NOT a punctuation mark, a whitespace character or a statement separator. IE you can't just produce a single quine made of punctuation marks, and say it is both A and B. – abligh – 2014-08-16T20:15:35.787Can you use space/tab in python? It's part of the statement separator, just not always. – isaacg – 2014-08-17T09:35:35.570
Your definition of whitespace is wrong.
print("Hello, World!")
is not the same aspri nt("Hello, World!")
. – Doorknob – 2014-08-17T09:47:57.103I guess Python is out. Can't imagine any of A or B not having a
print
command, causing both programs containing these 5 characters. (sys.stdout.write
containsr
,i
andt
as well.) – Falko – 2014-08-17T16:32:49.563@isaacg you can use whitespace in any language (including Python), but there must also be non-whitespace characters. – abligh – 2014-08-17T16:58:23.537
@Doorknob thanks - I've clarified that. – abligh – 2014-08-17T17:01:44.647
1For the purposes here, are
A
anda
considered different "characters"? – HostileFork says dont trust SE – 2014-08-17T17:33:44.2301It would be better if you provided a complete list of ASCII characters that match rule 5. – aditsu quit because SE is EVIL – 2014-08-17T18:37:03.333
So, if
A
has 'class',B
would have to use 'CLASS'? – Οurous – 2014-08-17T22:52:00.693@Ourous: If
A
has 'class',B
would have to have something other thanclass
;CLASS
is but one option. – abligh – 2014-08-17T23:47:29.693@aditsu: the POSIX word character class consists of the letters a-Z, A-Z, the numbers 0-9 and underscore (_). – abligh – 2014-08-17T23:48:24.663
@abligh that's not what I asked.. – aditsu quit because SE is EVIL – 2014-08-17T23:57:10.630
@aditsu I've made the rule rather simpler (similar to the definition of
ispunct()
). – abligh – 2014-08-18T07:40:49.413