Quine.zip

Below are two textboxes. The one on the left is for input, and the one on the right displays output. The goal here is to write a series of commands on the left that results in output matching exactly what's on the left. In the world of programming, such a series of commands is called a quine The commands available to you are: print M : prints the following M lines of input . Any command that is printed will not be run as an action.

: prints the following lines of . Any command that is printed will not be run as an action. repeat M N: repeats the last M lines of output, starting N lines from the end. In both commands, M is a whole number (e.g. 0, 1, 2, ...) In the repeat command, N is a natural number (e.g. 1, 2, 3, ...) Yes, such a quine is possible, and no, I won't tell you what it is. Only one command per line, please.

Examples:

print 2 print 3 print 4 repeat 1 1 Input: print 3 print 4 print 4 Output: print 0 print 2 print 1 print 2 repeat 3 2 Input: print 1 print 2 print 1 print 2 print 1 Output:

More info:

The set of print/repeat commands is based on the LZ77 decompression scheme used in ZIP file decompression. Basically, all ZIP files consist of opcodes that represent these commands, and because a quine exists for them, it's possible to create a ZIP file that unzips to itself. Cool beans.

I came across a puzzle just like this years ago, but couldn't find it again. I thought it was too cool of a puzzle to be lost to the aether, and so here we are!

For those interested in learning more about this quine, here are a couple blog posts on the topic:

The source for this page is on Github at wgreenberg/quine.zip.

The colorscheme for this page is based on Ethan Schoonover's awesome Solarized palette which is licensed under the MIT License.