A Multipurpose Quine

5

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)

KrystosTheOverlord

Posted 2019-01-31T03:24:27.407

Reputation: 681

Comments are not for extended discussion; this conversation has been moved to chat.

– James – 2019-01-31T16:26:00.423

Seems really close to the quine chaining challenge without as good of a specification. – Magic Octopus Urn – 2019-01-31T18:49:28.857

2I'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. – James – 2019-01-31T20:59:44.813

I suggest stating that each quine must be at least n levenshtein distance from each other, where n is a number of your choosing. – Embodiment of Ignorance – 2019-01-31T21:40:30.210

https://en.m.wikipedia.org/wiki/Levenshtein_distance – Embodiment of Ignorance – 2019-01-31T22:41:01.737

I think this new edit makes this challenge meet the requirements of this site. I would cast a reopen vote if I could, but the system doesn't let me because I cast one already before. – Embodiment of Ignorance – 2019-02-05T19:38:51.127

1

I have created a post on meta for you: https://codegolf.meta.stackexchange.com/questions/17365/should-a-multipurpose-quine-be-reopened

– Embodiment of Ignorance – 2019-02-06T21:45:20.467

This doesn't really stop me from outputting infinite quines that are more than n/4 characters away from each other, e.g. the ><> quines 'rd3*>o<, 'rd3*>o<0000, 'rd3*>o<00000000 etc. – Jo King – 2019-02-07T13:06:42.490

What constitutes a different language here? Our "default" definition is to say that different implementations are different languages (see here) which is quite fine grained and might not be suited to the challenge. Did you mean something else?

– Post Rock Garf Hunter – 2019-02-14T21:22:01.147

Answers

3

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.

Jo King

Posted 2019-01-31T03:24:27.407

Reputation: 38 234

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 – KrystosTheOverlord – 2019-03-05T16:30:11.370

Try adding mystic runes, or Lost – KrystosTheOverlord – 2019-03-06T03:52:13.950

@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

– Jo King – 2019-03-06T03:54:21.323

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 – KrystosTheOverlord – 2019-03-06T04:00:59.030

1

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

KrystosTheOverlord

Posted 2019-01-31T03:24:27.407

Reputation: 681