Write two programs such that when the bytes of their source code are XOR-d together it produces a third, valid program, all in the same language. The length of each of the three programs in bytes must be identical.
The first program should output A
. The second program should output B
. The third program should output C
.
A newline is optional, but if one outputs a newline, both of the others must too.
If you use any command line flags you must you the same ones for each program, i.e. all three programs must be executed the same way. If you're using a language like PHP that traditionally starts with the same combination of characters, e.g. <?
but there is a command line option that drops those characters you may use that instead, i.e. PHP must only be run from the command line.
No input is allowed. Each program must be self-contained.
If your program is written entirely in ASCII the following tables might help:
Codes 0x20 - 0x3F
!"#$%&'()*+,-./
0123456789:;<=>?
Codes 0x40 - 0x5F
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
Codes 0x60 - 0x7E
`abcdefghijklmno
pqrstuvwxyz{|}~
EDIT
Using non-printing characters is allowed as I didn't expressly forbid it originally. However, if you want to post a version that uses only printable characters as well that would be great! (Score whichever is the shortest.) The "clever factor" of using control codes has somewhat worn off now...
END EDIT
XOR-ing any two codes from the same block will produce a code less than 0x20 which is therefore not a valid printable ASCII code, e.g. 0x41 (A
) XOR 0x5A (Z
) = 0x1B. XOR-ing any two codes from different blocks will produce a code from the third block, e.g. 0x61 (a
) XOR 0x54 (T
) = 0x35 (5
).
| @` !Aa "Bb #Cc $Dd %Ee &Ff 'Gg (Hh )Ii *Jj +Kk ,Ll -Mm .Nn /Oo 0Pp 1Qq 2Rr 3Ss 4Tt 5Uu 6Vv 7Ww 8Xx 9Yy :Zz ;[{ <\| =]} >^~ ?_
--- + --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@` | @` !Aa "Bb #Cc $Dd %Ee &Ff 'Gg (Hh )Ii *Jj +Kk ,Ll -Mm .Nn /Oo 0Pp 1Qq 2Rr 3Ss 4Tt 5Uu 6Vv 7Ww 8Xx 9Yy :Zz ;[{ <\| =]} >^~ ?_
!Aa | !Aa @` #Cc "Bb %Ee $Dd 'Gg &Ff )Ii (Hh +Kk *Jj -Mm ,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<\| =]} :Zz ;[{ 8Xx 9Yy 6Vv 7Ww 4Tt 5Uu 2Rr 3Ss 0Pp 1Qq .Nn /Oo ,Ll -Mm *Jj +Kk (Hh )Ii &Ff 'Gg $Dd %Ee "Bb #Cc @` !Aa
?_ | ?_ >^~ =]} <\| ;[{ :Zz 9Yy 8Xx 7Ww 6Vv 5Uu 4Tt 3Ss 2Rr 1Qq 0Pp /Oo .Nn -Mm ,Ll +Kk *Jj )Ii (Hh 'Gg &Ff %Ee $Dd #Cc "Bb !Aa @`
Look up two characters from different columns and pick the character from their intersection that's in the other column, e.g. B
and e
: "Bb
XOR %Ee
is 'Gg
. B
is second column and e
is third column so pick the character from the first column in 'Gg
: '
.
Example source:
Ld+|?dpHs'-,pUe (Program 1)
~bWn=n5Xe!t_G($3 (Program 2)
^.3EAQQ(-RSrkXqV (Program 3)
Note that in each column there can only be one digit, one uppercase letter and one lowercase letter. For each column you may use any character you like in the first program, then your choice of 64 characters in the second program but only one possible character in the third program. 0x7F is not valid anywhere.
If you use Unicode it's up to you to validate the XOR-ing and you must say how it's encoded, e.g. UTF-8, UTF-16, etc. Each file must use the same encoding.
Score: Length of one program. Fewest bytes win!