1
\$\begingroup\$

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!

\$\endgroup\$
  • \$\begingroup\$ Just want to clarify, do all common rules apply; and for the rectangle scoring system is the Levenshtein distance threshold for this challenge 85%? \$\endgroup\$ – Albert Renshaw Mar 16 '17 at 21:15
  • \$\begingroup\$ @AlbertRenshaw yes \$\endgroup\$ – Christopher Mar 16 '17 at 21:23
  • \$\begingroup\$ "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? \$\endgroup\$ – user41805 Mar 25 '17 at 16:40
  • \$\begingroup\$ Possibly related: Hello world with the shape of hello world \$\endgroup\$ – Matthew Roh Mar 25 '17 at 17:33
  • \$\begingroup\$ 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). \$\endgroup\$ – user62131 Mar 25 '17 at 23:22
5
\$\begingroup\$

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
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Dang. That is impressive, good job! \$\endgroup\$ – Christopher Mar 27 '17 at 15:10
  • \$\begingroup\$ If you want to make me smile (I would offer a upvote but you already got it) add a explanation \$\endgroup\$ – Christopher Mar 27 '17 at 15:11

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.