5
\$\begingroup\$

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

Challenge

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)

EX:

Starting program:

James

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

James

Given 1 as input, the code outputs:

Kendra

Given 2 as input, the code outputs:

Alexander

And so on...

Requirements

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

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)

\$\endgroup\$
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – DJMcMayhem Jan 31 at 16:26
  • \$\begingroup\$ Seems really close to the quine chaining challenge without as good of a specification. \$\endgroup\$ – Magic Octopus Urn Jan 31 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 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\$ – Embodiment of Ignorance Jan 31 at 21:40
  • 1
    \$\begingroup\$ I have created a post on meta for you: codegolf.meta.stackexchange.com/questions/17365/… \$\endgroup\$ – Embodiment of Ignorance Feb 6 at 21:45
3
\$\begingroup\$

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

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

Try it online!

Verification!

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.

\$\endgroup\$
  • \$\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 at 16:30
  • \$\begingroup\$ Try adding mystic runes, or Lost \$\endgroup\$ – KrystosTheOverlord Mar 6 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 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 at 4:00
1
\$\begingroup\$

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...

\$\endgroup\$
-2
\$\begingroup\$

C# (Visual C# Interactive Compiler), and all valid combinations of the /u, -u, /r, -r, -using, /using flags, 181 bytes, Score: Infinite

var s="var s={0}{1}{0};for(var i=double.Parse(ReadLine()??{0}0{0})*99;i-->0;s+='/');Write(s,(char)34,s)";for(var i=double.Parse(ReadLine()??"0")*99;i-->0;s+='/');Write(s,(char)34,s)

Since the meta-consensus is that different flags are considered as different langauges, this is valid (I think). How this works is that /r and -r flags are assembly references that don't affect the code, since we don't need any assembly references. /u, -u, -using, and -using are import flags, so it doesn't really affect the code. So /u:System is different from /u:System;System, which is then different from /u:System;System;System, and so on.

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm not the most familiar with C#, but how are those flags counted as different programming languages? If it is a part of C#, then it doesn't exactly count, if my rules allow for this, let me know and I'll fix it \$\endgroup\$ – KrystosTheOverlord Mar 7 at 3:43
  • \$\begingroup\$ @KrystosTheOverlord Here: codegolf.meta.stackexchange.com/a/14339/84206 \$\endgroup\$ – Embodiment of Ignorance Mar 7 at 3:51
  • \$\begingroup\$ @KrystosTheOverlord each separate invocation of a compiler/interpreter/whatever a separate implementation (and thus a separate language by our rules). from the post above \$\endgroup\$ – Embodiment of Ignorance Mar 7 at 3:52

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.