5 added 2257 characters in body
source | link
{`As_W%er"_~"+'`As_W%er"_~"+S 33*F'qt133*F'Lt1{\}*N\}_~
               qL                 
               qL                 
{`As_W%er"_~"+'`As_W%er"_~"+S 33*F'qt033*F'Lt0{\}*N\}_~

How it works

I'll addFirst, you should understand the basic CJam quine:

{"_~"}_~

The braces simply define a block of code, like a function, that isn't immediately executed. If an explanation after checking if Iunexecuted block remains on the stack, it's source code (including braces) is printed. _ duplicates the block, and ~ executes the second copy. The block itself simply pushes the string containing _~. So this code, leaves the stack in the following state:

Stack: [{"_~"} "_~"]

The block and the string are simply printed back-to-back at the end of the program, which makes this a quine.

The beauty of this is that we can golfdo whatever we want in the block, and it remains a quine, because each piece of code will automatically be printed in the block contents. We can also modify the block, by obtaining it's string representation with ` (which is just a string of the block with braces).

Now let's look at this down furthersolution. Notice that either part of the mutual quine contains of the quine-like block with _~, and an L. The L pushes an empty string onto the stack, which doesn't contribute to the output. So here is what the block does:

`                             "Convert block to its string representation.";
 As                           "Push 10 and convert to string.";
   _W%                        "Duplicate and reverse, to get another string 01.";
      er                      "Swap 0s and 1s in the block string.";
        "_~"+                 "Append _~.";
             S 33*            "Push a string with 33 spaces.";
                  F'Lt        "Set the character at index 15 to L.";
                      1{ }*   "Repeat this block once.";
                        \     "Swap the code string and the space string.";
                           N\ "Push a newline and move it between the two lines.";

So this will do the quine part, but exchange a 1 for a 0, and it will also prepend another line with an L, where the code above has a space. The catch is that the order of those two lines is determined by the swapping inside { }*. And because the outer part of the mutual quine has the 0 in front of it replaced by a 1, it never executes this swap, and hence produces the original order again.

{`As_W%er"_~"+' 33*F'qt1{\}*N\}_~
               q                 
               q                 
{`As_W%er"_~"+' 33*F'qt0{\}*N\}_~

I'll add an explanation after checking if I can golf this down further.

{`As_W%er"_~"+S 33*F'Lt1{\}*N\}_~
               L                 
               L                 
{`As_W%er"_~"+S 33*F'Lt0{\}*N\}_~

How it works

First, you should understand the basic CJam quine:

{"_~"}_~

The braces simply define a block of code, like a function, that isn't immediately executed. If an unexecuted block remains on the stack, it's source code (including braces) is printed. _ duplicates the block, and ~ executes the second copy. The block itself simply pushes the string containing _~. So this code, leaves the stack in the following state:

Stack: [{"_~"} "_~"]

The block and the string are simply printed back-to-back at the end of the program, which makes this a quine.

The beauty of this is that we can do whatever we want in the block, and it remains a quine, because each piece of code will automatically be printed in the block contents. We can also modify the block, by obtaining it's string representation with ` (which is just a string of the block with braces).

Now let's look at this solution. Notice that either part of the mutual quine contains of the quine-like block with _~, and an L. The L pushes an empty string onto the stack, which doesn't contribute to the output. So here is what the block does:

`                             "Convert block to its string representation.";
 As                           "Push 10 and convert to string.";
   _W%                        "Duplicate and reverse, to get another string 01.";
      er                      "Swap 0s and 1s in the block string.";
        "_~"+                 "Append _~.";
             S 33*            "Push a string with 33 spaces.";
                  F'Lt        "Set the character at index 15 to L.";
                      1{ }*   "Repeat this block once.";
                        \     "Swap the code string and the space string.";
                           N\ "Push a newline and move it between the two lines.";

So this will do the quine part, but exchange a 1 for a 0, and it will also prepend another line with an L, where the code above has a space. The catch is that the order of those two lines is determined by the swapping inside { }*. And because the outer part of the mutual quine has the 0 in front of it replaced by a 1, it never executes this swap, and hence produces the original order again.

4 edited body
source | link

CJam, 42 37 33 x 2 = 66

{`As_W%er"_~"+' 33*F'qt1{\}*N\}_~
               q                 

which prints

               q                 
{`As_W%er"_~"+' 33*F'qt0{\}*N\}_~

(The lines are swapped, and a 1 turns into a W0.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

CJam, 42 37 33 x 2 = 66

{`As_W%er"_~"+' 33*F'qt1{\}*N\}_~
               q                 

which prints

               q                 
{`As_W%er"_~"+' 33*F'qt0{\}*N\}_~

(The lines are swapped, and a 1 turns into a W.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

CJam, 42 37 33 x 2 = 66

{`As_W%er"_~"+' 33*F'qt1{\}*N\}_~
               q                 

which prints

               q                 
{`As_W%er"_~"+' 33*F'qt0{\}*N\}_~

(The lines are swapped, and a 1 turns into a 0.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

3 deleted 6 characters in body
source | link

CJam, 42 3737 33 x 2 = 7466

{`"W1"_0(%er"_~"+'`As_W%er"_~"+' 37*I'qta\a+1%N*33*F'qt1{\}*N\}_~
                  q                  

which prints

                  q                  
{`"1W"_0(%er"_~"+'`As_W%er"_~"+' 37*I'qta\a+W%N*33*F'qt0{\}*N\}_~

(The lines are swapped, and a 1 turns into a W.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

CJam, 42 37 x 2 = 74

{`"W1"_0(%er"_~"+' 37*I'qta\a+1%N*}_~
                  q                  

which prints

                  q                  
{`"1W"_0(%er"_~"+' 37*I'qta\a+W%N*}_~

(The lines are swapped, and a 1 turns into a W.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

CJam, 42 37 33 x 2 = 66

{`As_W%er"_~"+' 33*F'qt1{\}*N\}_~
               q                 

which prints

               q                 
{`As_W%er"_~"+' 33*F'qt0{\}*N\}_~

(The lines are swapped, and a 1 turns into a W.)

Test it here.

I'll add an explanation after checking if I can golf this down further.

2 deleted 20 characters in body
source | link
1
source | link