45
10
Background
As most PPCG regulars will know, a quine is a program which outputs its own source code when run; and the Levenshtein distance between two strings is the minimum number of insertions, deletions, and edits needed to change one string into the other. In this challenge, we're combining the two concepts into a "levenquine": a program that outputs its own source code, but with one instance of one character inserted, deleted, or replaced with a different character. (In other words, the Levenshtein distance between the program and its output is 1.)
The task
Write a levenquine such that its output is a levenquine, the output of that program is also a levenquine, and so on. Additionally, at some point, the sequence of repeatedly running the program, running its output, running its output's output, etc. must eventually come back to the original program.
There's one additional restriction that makes things much harder: there must be two distinct programs somewhere within this cycle which have no characters in common (in other words, there's no character that exists within one program and also exists within the other program). Your program is therefore going to have to gradually transform itself into a different character set, and back again.
If you're using a programming language which has unavoidable boilerplate that's required in any program that produces output (e.g. it only has one way to write a print
statement and no other useful forms of output), you may treat that boilerplate as nonexistent for the purpose of determining which characters two programs have in common. You must, however, still count that boilerplate for the purpose of determining the Levenquine property of the code.
Clarifications
- Each of the "programs" in the cycle can be either a full program or a function. They don't all have to be the same, e.g. some could be full programs and some could be functions.
- Not all the programs in the cycle need to use the same form of output. For example, some could output via standard output, and some could output via standard error.
- Your programs will be run with no input (or in languages which require input to do anything at all, the simplest possible input).
- Proper quine rules apply; although a Levenquine is not a true quine, you may not do anything that would be illegal when writing a proper quine. In particular, the null program is never valid output from a proper Levenquine (and thus cannot be part of your cycle).
- The Levenquine restriction is measured in terms of characters, rather than bytes (e.g.
ê
is one character even when the source is encoded in UTF-8). The no-characters-in-common restriction is also measured in terms of characters. The victory condition, however, counts in bytes.
Victory condition
Please submit at least the following three programs from the cycle: the shortest program (measured in bytes); and two programs from the cycle that have no characters in common. It's possible that two of these are the same, and it's also possible that all three are distinct. The score is based on the length in bytes of the shortest program, with shorter being better, thus making this a kind of code-golf competition.
For people who can see deleted posts: the Sandbox post was here.
– None – 2017-04-11T21:45:30.837I think it'd also be good for answers to include the length of the cycle. – mbomb007 – 2017-04-11T21:54:31.703
What if, say, the language has several functions for performing output, but they all pairwise share characters? – Ørjan Johansen – 2017-04-11T23:45:59.497
2@ØrjanJohansen: I guess I wouldn't be too opposed to just picking one of them and sticking with it in that case. However, it's arguably noncompeting; I wanted the rule to be objective, because otherwise people have a tendency to try to poke loopholes in it, and if you try to make the rule too complex there tend to be arguments over what it means. – None – 2017-04-12T01:00:31.863
Can it be a levenquine bit-wise? As in the distance from the original source code is 1 byte off? – Magic Octopus Urn – 2017-10-31T20:28:54.720