Bowl a rectangular quine

1

1

Code-Bowling Quine Challenge

You must bowl a quine following the rules of code bowling and quines but the source code must be in the shape of a rectangle (details specified below)


Quine

Quines returned must be returned via the ways defined in the standard I/O rules.


Rules

Code-Bowling Rules

  1. Character : Byte Ratio In Code-Bowling a character-count is preferred over a byte-count. The obvious reasoning for this is that multi-byte unicode characters (e.g. ) can be used in place of single-byte unicode characters to fluff up byte count and will make bowling more about who renames the most variables with high-byte unicode characters rather than who most strategically creates meaningful complex code. (See Useful tools section at end for character-counting widget)

  2. Variable/Function/Object Names All variable names (or object pointers, function names, etc) should be 1 character long. The only acceptable time to use 2-character variables names is after all possible 1-character variables have been used. The only acceptable time to use 3-character variables names is after all possible 2-character variables have been used. Etc.

  3. Non-simplified Arithmetic All arithmetic should be in simplified form unless there is a justifiable reason for doing otherwise (e.g. circumventing penalties defined in the scoring system of the challenge (In which case you still must use the smallest possible alternative form)). Finding the simplified form of any equation (as well as a list of small alternative forms) is easy to do using Wolfram|Alpha. (See Useful tools section at end)

  4. Un-used Code All code must be used. Meaning the program must fail to always properly complete the task if any individual character (or varying set(s) of characters) is/are removed. Naturally, a subset of the program should not be able complete the task on its own without the rest of the program.

  5. Line-breaks and White-space Unless necessary for code function or otherwise specified by the challenge, all line-breaks and white-space should be removed from code before scoring by counting characters.

  6. Comments Comments are not permitted towards character-count, unless somehow utilized by your program/function.

Rectangle Rules

Your code must be in the shape of a rectangle, i.e. every line has the same number of characters. Your code must have at least 2 lines, with at least 3 chars on each line.

Also, each line of code must be distinct to a certain threshold. Distinctness is calculated using the Levenshtein distance. The threshold is 85%, meaning the Levenshtein distance between any two lines must be greater than or equal to 0.85*w, where w is the number of characters used in a line of your rectangle.

And for convenience, here is a Levenshtein distance calculator and a character length calculator.


Scoring

This is a variant. The program with the highest number of characters wins!

Christopher

Posted 2017-03-16T21:01:38.190

Reputation: 3 428

Just want to clarify, do all common rules apply; and for the rectangle scoring system is the Levenshtein distance threshold for this challenge 85%? – Albert Renshaw – 2017-03-16T21:15:00.493

@AlbertRenshaw yes – Christopher – 2017-03-16T21:23:00.203

"Meaning the program must fail to always properly complete the task if any individual character (or varying set(s) of characters) is/are removed." Can fail also mean that removing characters prevents the code from being a rectangle? – user41805 – 2017-03-25T16:40:29.370

Possibly related: Hello world with the shape of hello world – Matthew Roh – 2017-03-25T17:33:42.927

I'd be disappointed if you couldn't score infinity in the limit on this one (the only difficult part would be creating a checksum operation that can handle having arbitrary subsets of bytes deleted from it). – None – 2017-03-25T23:22:51.727

@ais523 it would fail un needed bytes – Christopher – 2017-03-26T00:36:25.677

@DownChristopher: All the bytes are needed because the checksum wouldn't match otherwise, thus causing the code to fail to work. This is a common trick used in "all the bytes must matter" [tag:restricted-source] questions. – None – 2017-03-26T01:27:16.280

@ais523 It's possible that the checksum part of the code itself could be removed as well. No subset of the program should be able to complete the task. Granted I dont know exactly how the check sum code works, need an example to tell – Albert Renshaw – 2017-03-28T02:09:22.597

A trick that would probably work would be to make the checksum executable code, and eval it. Removing the checksum would mean that part of the code doesn't run, and thus the program fails. Removing any of the part of the code that gets checksummed would cause the wrong code to run. The only really hard part is designing the checksum in such a way that you can't find a subset of the code that would sum to the same value. – None – 2017-03-28T03:51:45.850

Answers

5

Python 3, 89 bytes

a='a=%r;b=%r;p=\\';b='print;p(a%(a,b));';p=\
print;p(a%(a,b));c='c=%r;p(b+c%%c)';p(b+c%c)

Try it online

The Levenshtein distance is 38, which is 86.36% of 44.

Explanation:

This is similar to the standard quine s='s=%r;print s%%s';print s%s. I had to try a lot of combinations and modifications in order to find my program. Creating the function p was used to make the second line shorter. The \ on the end of the first line is a line-continuation character.

a

a='a=%r;b=%r;p=\\'
  • A string template that results in the first line

b

b='print;p(a%(a,b));'
  • String that represents the first part of the 2nd line

p

p=\
print
  • Shorten stuff, change lengths

line 1

p(a%(a,b))
  • Print the first line

c

c='c=%r;p(b+c%%c)'
  • String representing itself plus the part after that prints b

line 2

p(b+c%c)
  • Outputs the second line

mbomb007

Posted 2017-03-16T21:01:38.190

Reputation: 21 944

Dang. That is impressive, good job! – Christopher – 2017-03-27T15:10:23.733

If you want to make me smile (I would offer a upvote but you already got it) add a explanation – Christopher – 2017-03-27T15:11:37.680