I personally love quines, but they all seem to be so... static. So why not create a quine that can do more.


The challenge here is to create a quine that without any sort of input is a normal quine. Then if it receives a different input, it outputs a different quine in a different language. (basically like a polyglot, but it doesn't have to return to the original source code)


Starting program:


Given no input or 0 as input, the code above outputs:


Given 1 as input, the code outputs:


Given 2 as input, the code outputs:


And so on...


Like with any other quine challenge, no examining source code directly!

Inputs are either nothing, or a positive integer.

Each quine must not be less than \$\lceil(n/4)\rceil\$ levenshtein distance from all other quines, where \$n\$ is the length of the original quine. Look at this example program:

Bobb  //original quine
Bobby //output (when given an input), we'll name him bobby
Bob   //output (when given a different input), we'll name him bob

The above is not valid, because Bob is only one levenshtein distance from Bobb.

However, this one is valid:

Bob      //original quine
Alice    //bob's output when given 1 as input
Geronimo //bob's output when given 2 as an input

Because \$ ceil(len(bob)/4)=1 \$, and Alice, Geronimo, and Bob are all at more than one levenshtein distance away from each other.

There has to be a minimum of one extra quine to be outputted.

The quine must output itself when given no input or 0, and output a different quine if given a different integer input!


Points are based on this equation (courtesy of Luis felipe De jesus Munoz) $${\frac{100}{\text{bytes}} \cdot 2^{\text{extra quines} - 1}}$$

(100 divided by the number of bytes multiplied by 2 to the power of every different quine that your program can output, minus one to make sure the program at least outputs one different quine)

  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – DJMcMayhem Jan 31 '19 at 16:26
  • \$\begingroup\$ Seems really close to the quine chaining challenge without as good of a specification. \$\endgroup\$ – Magic Octopus Urn Jan 31 '19 at 18:49
  • 2
    \$\begingroup\$ I'm sorry, but this question is still entirely unclear. An extra quine only counts when it is not just appending, deleting or inserting characters into another quine format. That means that the outputs cannot be altercations of each other, nor can they be altercations of the original. Every string is just some other string with characters deleted and/or inserted. So the task would be impossible. And it's not clear what you mean by "altercation". Also, you didn't say anything about polyglots in the spec. \$\endgroup\$ – DJMcMayhem Jan 31 '19 at 20:59
  • \$\begingroup\$ I suggest stating that each quine must be at least n levenshtein distance from each other, where n is a number of your choosing. \$\endgroup\$ – Gymhgy Jan 31 '19 at 21:40
  • 1
    \$\begingroup\$ I have created a post on meta for you: codegolf.meta.stackexchange.com/questions/17365/… \$\endgroup\$ – Gymhgy Feb 6 '19 at 21:45

Befunge-98, ><>, Fission, Wumpus, Cardinal, Gol><> and Beeswax, Score: \$(100/103)*2^6 = 62.136\$


Try it online!


When given an input of 0, this program produces itself. When given a different number, it produces the quines in the format

"[0#34o+]l2:)&o@.0*74#!,!?:o1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #_4F.~6.@1~0@D~FJR'!+!7,++tttt=++%88-$@,kJ'$.k+bf:k+bfj*a!:&,k-.#!0+df+c+f7

Where the 1s are the input number. Since there are 26 copies of the 1, this makes each quine distinct at least \$bytes/4\$ Levenshtein distance. The quines are entirely interchangeable as no program actually cares about the number part. I might see if I can add some more 2D languages to this (I'm thinking Cardinal Gol><> next) Don't have one in mind right now.

  • \$\begingroup\$ Very nice, this is really good, I'm guessing here that most of these output quines work in each language you are using, since they all look like they are the same format \$\endgroup\$ – KrystosTheOverlord Mar 5 '19 at 16:30
  • \$\begingroup\$ Try adding mystic runes, or Lost \$\endgroup\$ – KrystosTheOverlord Mar 6 '19 at 3:52
  • \$\begingroup\$ @KrystosTheOverlord I don't know Mystic Runes (perhaps you mean Runic Enhancements? I don't really know that either), and Lost would be terrible, since it would have to be multi-line. I'm currently working on adding Beeswax \$\endgroup\$ – Jo King Mar 6 '19 at 3:54
  • \$\begingroup\$ I meant Runic enchantments (I knew i got the name wrong), also, good job with the number of quines you have managed, you have really embodied this challenge \$\endgroup\$ – KrystosTheOverlord Mar 6 '19 at 4:00

JAVA -> ><>, (100/460 bytes)*2^0 = a score of .217... yay

import java.util.Scanner;public class M{public static void main(String args[]){Scanner i=new Scanner(System.in);String s="import java.util.Scanner;public class M{public static void main(String args[]){Scanner i=new Scanner(System.in);String s=%c%s%c;if(i.nextInt()==0){System.out.printf(s,34,s,34,34,34);return;}System.out.println(%c'r3d*d8*7+e0p>>|%c);}}";if(i.nextInt()==0){System.out.printf(s,34,s,34,34,34);return;}System.out.println("'r3d*d8*7+e0p>>|");}}

I'm not winning my own challenge, but this should serve as an example.

If it gets and input of 0 then it outputs the java quine, if it receives a 1 then it outputs a ><> quine (courtesy of mbomb007). And that is it...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.