-1
Introduction
A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of the original program. Note that the number of chained programs does not have to be 3; it could be 2, 4, or 97384.
Challenge
Your task is to write a polyglot iterative quine. Each program in the program chain must be a polyglot.
- Each of your programs must take no input.
- As stated above, each of the programs must output the source of the next program in the chain. The last program in the chain must output the source code of the first program.
Scoring
Your score is calculated as follows:
- For each program in the chain, take the number of languages it is valid in. Sum the results.
- Sum the byte count of each program in the chain.
- Divide the byte count by the number from the first program.
Rules
- The length of the chain must be at least 2.
- Each program in the chain must be valid in at least 2 languages.
- The program with the lowest score wins.
- "Different language" is defined as follows:
- A language where the source code of the compiler or interpreter is not the same as another, and the compiler or interpreter does not run the same language as another. Some examples of different languages are: Python 2 and 3, C and C++, Java and C, and Lua and Ruby. However, by this definition, using
tcc
instead ofgcc
does not count as a different language, becausetcc
runs the same language asgcc
: C.
- A language where the source code of the compiler or interpreter is not the same as another, and the compiler or interpreter does not run the same language as another. Some examples of different languages are: Python 2 and 3, C and C++, Java and C, and Lua and Ruby. However, by this definition, using
- Programs are allowed to throw errors, but only after they print out the output of the program. For example,
print(1/0);print(<quine stuff>)
in Python 3 would be invalid, butprint(<quine stuff);print(1/0)
would be.
In order for this sort of challenge to work it is going to need to be clear what counts as different languages. Otherwise we get a lot of questions as to whether all versios of python are the same language, whether using different C compilers counts as using different language etc. Related reading
– Post Rock Garf Hunter – 2019-12-11T21:12:59.223@WheatWizard - ok, I will fix that – sugarfi – 2019-12-11T21:19:23.147
this already won. – Draco18s no longer trusts SE – 2019-12-11T21:39:23.950
1@Dracos18s Those aren't polyglots – Jo King – 2019-12-11T22:25:00.050
Couldn't I just make a BF quine, and say it iterates through the hundreds of trivial BF variants? – Redwolf Programs – 2019-12-11T23:41:10.220
No - if the BF variants are also able to compile a normal BF quine, then it can be said that they perform the same task as the original compiler, rendering them not different languages. – sugarfi – 2019-12-11T23:45:14.280
3What do you mean by "number of languages it is valid in"? Number of languages where that source code can be run without errors? Or without syntax errors? Is
print(1/0)
considered valid in Python 3, for example? – 79037662 – 2019-12-11T23:58:51.843I mean the number of languages it can be run in without throwing any errors. Compiler warnings are not counted. – sugarfi – 2019-12-12T00:50:05.623
1If I prefix my code with a comment character (e.g.
#
, does my score suddenly decrease because it can be run in hundreds of different languages with erroring? On the other hand, my><>
program works perfectly fine but terminates in an error (which is also fine by community standards). Perhaps you should just say the program has to output the next program in the sequence for each language and leave it at that? – Jo King – 2019-12-12T07:37:44.797@JoKing - ok, here is the new rule: the program must output the source of the next program without any errors beforehand. Any errors afterward, including terminating with an error, are fine. – sugarfi – 2019-12-12T21:54:41.177
Is that any different to just saying that it has to output the source of the next program, without all the stuff about errors? Also, make sure to add these corrections to the question itself – Jo King – 2019-12-12T22:31:39.197
@JoKing - good point. I will edit the question. – sugarfi – 2019-12-12T23:38:39.837