Code two programs where each of the programs outputs both source codes interlaced per character like a zipper, a Double-slit Quine. The output from a Double-slit Quine is starting with the first character from the source code of the first program. If the source code of one of the programs is shorter in length than the other, then the rest of the output must be filled with the rest of the longer source code.


  1. You can use any programming language for both programs, not necessary the same programming language for both.
  2. Your programs should not take any input from a file, file name, network, the other program or anything else.

Mandatory criteria:

  • There is a catch, somewhere in the output the word QUINE in capital letters must exist, uninterrupted.
  • You need to state what two programming languages you are using. If you are using the same programming language for both, then you only need to state one programming language.
  • Both programs should be able to execute, or be interpreted, respectively independent of the other program.


Having this example source code of program one:


Having this example source code of program two:


Then the valid Double-slit Quine output from both programs must be:


This is code-golf, the least bytes when summing the length of both source codes, and obviously also the length of each programs output, wins!

  • \$\begingroup\$ Each individual program doesn't have to be a quine also, correct? And must each program contain at least one character? \$\endgroup\$
    – mbomb007
    May 29, 2015 at 20:25
  • \$\begingroup\$ @mbomb007 That is correct. Each individual program should output both source code characters like a zipper from start to end. Well, I guess you'll need at least 1 byte in a programing language to output QUINE? The output from both programs must be identical. \$\endgroup\$ May 29, 2015 at 20:28
  • \$\begingroup\$ I'm not sure I understand the rest of the output must be filled with the rest of the longer source code correctly. How would A and XYZ be interleaved? AXYZ? \$\endgroup\$
    – Dennis
    May 29, 2015 at 20:29
  • \$\begingroup\$ @Dennis Just like .+ or z works \$\endgroup\$
    – Optimizer
    May 29, 2015 at 20:30
  • \$\begingroup\$ @Dennis Correct. What is left from the longer source code when the shorter runs out of bytes must be appended to the output from both programs. \$\endgroup\$ May 29, 2015 at 20:31

4 Answers 4


CJam, 49 47 bytes




both print


Try it online: program 1, program 2, proof of validity

How they work

{                }   e# Push a code block.
                  _~ e# Execute a copy.
 `                   e# Convert the code block into a string.
  :_                 e# Duplicate each character of the resulting string.
    "__~~e#QUINE"    e# Push this string.

Program 1 finishes here and has a string representation of its entire source code (which each character repeated twice) as well as the string e#QUINE on the stack.

Program 2 additionally parses e#QUINE, which is a comment.

In both cases, CJam prints the two strings automatically, resulting in the aforementioned output.


Seriously, 46 56 42 bytes


Hex Dump:


The second program is this exact program reversed. It does contain an invisible character, but the byte count is correct. Both programs output this palindromic string:


(For some reason it displays the invisible character when it outputs it in my terminal. I don't really understand that 7F byte.)

How it works:

Q                     Push the source to the stack
 U                    Nop
  NX                  Push and pop lyrics to 99 bottles of beer
    ;R                Make a copy of the source reversed.
      Z               Zip them together.
       t              Completely flatten the list.
        dX            Delete the trailing newline
          εj          Join it into a string.
            .         Print it with a trailing newline.
             ⌂        (This is that 7F byte that won't show up. It halts.)

The rest of the program is not executed.

Then the other direction:

\n                   Nop
  Q                  Push the source code.
   IE                Nops
     R               Reverse source code to get source of first program
      £              Eval it into a function
       ƒ             Call it.

At this point, we are now running the first program above, so execution continues as described there.

I am heavily exploiting the fact that several commands do nothing to strings or empty stacks here. I'm also exploiting the unexpected behavior of t when there is only one item on the stack. Do not expect this program to work in future versions of Seriously.

As the online version of the Seriously interpreter continues to be broken, you'll have to download the interpreter and run it on your own machine to test it.

  • \$\begingroup\$ @Dennis did you test it on your computer? That may be an artifact of my own build environment. \$\endgroup\$
    – quintopia
    Dec 25, 2015 at 23:57
  • \$\begingroup\$ @Dennis nvm you're right. All of Seriously's output methods add a linefeed. I can fix it at the cost of 8 bytes. Looks like your method will be shorter (which is sad because this method is cooler IMO). \$\endgroup\$
    – quintopia
    Dec 26, 2015 at 2:13

GolfScript, 46 bytes




both print


Try it online: program 1, program 2, proof of validity

How it works


{                }    # Push a code block.
                  .~  # Execute a copy.
 `                    # Convert the code block into a string.
  {.}%                # Duplicate each character of the resulting string.
      "..~~QUINE"     # Push that string.

The source code of program 2 additionally parses QUINE\n, which are two undefined tokens.


Perl, 61+60=121 bytes

Program 1:


Program 2:


I thought I'd give this a go in a non-golfing language. This is basically just a universal quine constructor in Perl modified to double every character before printing it, and append QUINE to the end. Then we just have to stick a comment at the end of the code to compensate for the added text.

(I wrote this without really looking at the other answers. Turns out it'd be possible to save a byte by putting the entire comment in one program, but I'm not sure if I should just be blatantly copying algorithms like that.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.