Radiation hardened cyclic quine polyglot

10

Challenge

Write two programs that:

  • run in two different programming languages.
    • These may not be two versions of one language.
  • when one program is run, it outputs the second program, and vice versa.
  • The two programs must be different (no polyglots).

Here's the catch though:

  • The programs must be radiation hardened.
    • This means that when any set of $n$ (defined below) characters is removed from either of the two programs, their functionality is unaffected.
    • $n$ is defined as the number of characters that may be omitted with your program's functionality unaffected.
    • $n$ must be at least $1$.

Rules

  • Standard loopholes are disallowed.
  • Your programs must be proper cyclic quines. They may not read their own source code.
  • Scoring is performed as follows:
    • Your score is $\frac{S_1+S_2}n$
    • where $S_1$ and $S_2$ are the size of your first and second programs respectively…
    • and $n$ is as defined above.
  • This is a , lowest score wins.

Reward

As this challenge is difficult to answer, I will be giving a bounty to the first person to answer.

dkudriavtsev

Posted 8 years ago

Reputation: 5 781

Must the programs be proper quines? – Mego – 8 years ago

@Mego Whoops - forgot to mention that. Yes. – dkudriavtsev – 8 years ago

Well, "proper quine" isn't the right term since they're not quines, but it seems you understood what I meant. – Mego – 8 years ago

@Mego Yeah. I'll fix that now – dkudriavtsev – 8 years ago

Does "Two different programming languages" allow for the use of e.g. Python 2 and Python 3? What about Python 2.5 and Python 2.7? – Pavel – 8 years ago

@Phoenix Two different versions of a programming language are still one programming language. I should edit that in. – dkudriavtsev – 8 years ago

To confirm: after I remove n chars from program 1, should it output the second program, or the second program minus n chars? – Stephen – 8 years ago

@StephenS Second program. – dkudriavtsev – 8 years ago

10Personally, I don't think this really adds much to the semiquine and radiation-hardening quine challenges we've already had; both categories have already been thrown together in so many combinations that it's extremely hard to come up with a truly original combination. – ETHproductions – 8 years ago

2You should probably add some kind of reward for answering this. I feel like it's too extremely difficult for many people to want to try. I saw this had no answers and I was thinking "ooh a quine challenge, I love those!" but then I read ALL THE RULES and it completely deterred me. – MD XF – 8 years ago

@MDXF The description of the challenge is "radiation hardened multi-language cyclic quine". The list of rules is there to establish scoring and stop rule breaking, and to prevent the question from being closed as unclear. – dkudriavtsev – 8 years ago

Answers

3

Gol><> and ><>, (117 bytes + 117 bytes)/1 = 234

Gol><>

\\<<'3d*}}}}~}:r0<}!o::! ?>~~a<o>Hr~Kl a}}:?%2l}}}ss2"<<\\
\\<<'3d*}}}}~}:r0<}!o::! ?>~~a<o>Hr~Kl a}}:?%2l}}}ss2"<<\\

Try it online!

><>

\\<<"2ss}}}l2%?:}}a lK~rH>o<a~~>? !::o!}<0r:}~}}}}*d3'<<\\
\\<<"2ss}}}l2%?:}}a lK~rH>o<a~~>? !::o!}<0r:}~}}}}*d3'<<\\

Try it online!

Verification!

These two programs are the same, just reversed. They both follow the same general code structure.

Explanation (Gol><> on top, ><> on the bottom)

\\<<                           <<\\  Transition to the copy of the code that is not radiated
\\<<                           <<\\

                              "    Wrapping string literal over the rest of the code
                              '

                           ss2     Push the string character
                           *3d

                        }}}        Rotate the "<<\" to the correct end of the stack
                        }}}

                 }}:?%2l           Use the extra \ to replace a possible irradiated copy
                    }~}:

       ~     lK                    Duplicate the code
        ~~>? !::o!}<0r             Print a copy of the code in reverse

                a                  Push a newline
       a
    Hr                             Reverse, print the rest of stack and terminate
    >o<                            Print the rest of the stack and terminate

Jo King

Posted 8 years ago

Reputation: 38 234