# A Complementary Quine

Write a quine that outputs the complement of the source code from the smallest containing power of two. Here's an example:

IN : source
OUT: \r\x11\x0b\x0e\x1d\x1b


The largest code point in the string "source" is the letter u, which is 117. The smallest containing power of 2 would be 128, so all the code points are taken as complements from 128.

1. s: 128 - 115 = 13. Code point 13 is a carriage return.
2. o: 128 - 111 = 17. Code point 17 is "device control 1"
3. u: 128 - 117 = 11. Code point 11 is a vertical tab.

And et cetera. Here's another example:

IN : R¡Ṡ
OUT: ᾮὟƠ


The largest code point is the character Ṡ, which is 7776. The smallest containing power of 2 is 2^13 (8192), so each character is complemented from 8192.

All of the standard loopholes apply. A program must consist of some explicit data or code. A variable containing some data by default would be considered implicit data, and therefore not allowed.

If your language inevitably outputs a trailing newline, it can be disregarded.

• I think it's clear now, removed comment clutter. – Jonathan Allan Sep 6 '17 at 5:10
• If there is a 256 code point, would the next largest power of two be 256 or 512? – Dennis Sep 6 '17 at 5:54
• If the language automatically ends any output with a newline, can that newline be disregarded for the purposes of the challenge? – Luis Mendo Sep 6 '17 at 10:13
• @Dennis: 256. The complement would be a null byte. – Zach Gates Sep 6 '17 at 12:44
• @ZachGates That's intuitive in decimal mathematics, but in binary it's less so. For example, it's true that 2^8 is 256, but an 8 bit number is only capable of representing values from 0 to 255. It's your challenge of course, but it seems to implicitly care about binary representations. – Kamil Drakari Sep 6 '17 at 14:50

# Neim, 1 byte

𝕕


Try it online!

Uses Neim's code-page, where 𝕕 is byte 0xd0 (208) and the printed result, 0, is byte 0x30 (48) which is as required (256-208).

𝕕 is an instruction to get the nth element of a list. Both n and the list are implicit since they are missing and neim outputs implicitly too.

• Missing stack elements default to 0. Therefore, this is getting the 0th element of the list [0] (which is 0 implicitly converted to a digit list), which is 0. – Okx Sep 6 '17 at 8:37
• I hate Neim, because I can't see most of the characters while on my phone. – caird coinheringaahing Sep 6 '17 at 21:03

# Retina, 2 1 byte

P


## Outputs

0


## Explained

P actually has no special meaning in retina, but retina treats it like a regex against the input, and counts the matches. As there's no input, there's no matches, so it returns 0, which is the exact inverse of this.

Try it online!

This is using an older version of Retina, which outputs a newline with the zero. This is not the case in the latest version.

• In the latest commit, you can drop the õ, because Retina no longer prints trailing linefeeds by default. – Martin Ender Sep 6 '17 at 6:11
• Can't you use Pv (or P) to the same effect? – Neil Sep 6 '17 at 8:03
• Also a solution for Jelly. – Khuldraeseth na'Barya Sep 6 '17 at 23:54

# RProgN 2, 17 18 bytes

« .S{c$256\-o}r.  ## Output U àÒ\x85\x9DÜÎËÊ¤Ó\x91\x83\x8EÒà  Where \x numbers are to be considered literal. ## Explained « .S{c$256\-o}r.
«                   # Push a function based on the remainder of the program and run it.
 .                # Append a space to the end, which stringifies it. As the stringification removes unnecessary spaces, this re-adds the leading one, making it a valid quine.
S               # Convert it to a stack of characters.
{        }r    # Replace each character based on a function.
c             # Get the character code
\$256         # Push 256 literally.
\-       # Flip them and subtract, giving 255 - char code, which is equivalent to the bitwise not of the char code.
o      # Get the character this represents.
.   # Reduce with Concatenation, turning it back into a string. Implicitely output.


Try it online!

• Oh so RProgN uses cheaty js style source reading assumes – ASCII-only Sep 6 '17 at 3:42
• @ASCII-only Kind of. « has no idea what the original source code looks like, but it does know the array of 'concepts' that the source code was parsed into. When stringifying it, it just concatenates the stringifications of those concepts, which is why noops like spaces are ignored. – ATaco Sep 6 '17 at 3:44

# C, 178 bytes

char*u,*s="char*u,*s=%c%s%c;main(){char t[256];sprintf(t,s,34,s,34);for(u=t;*u;++u)*u=128-*u;puts(t);}";main(){char t[256];sprintf(t,s,34,s,34);for(u=t;*u;++u)*u=128-*u;puts(t);}


Try it online!

# JavaScript, 121 bytes

f=a=>[...a='f='+f].map(a=>(m=(a=a.charCodeAt())>m?a:m,a),m=0).map(a=>String.fromCharCode(2**-~(Math.log2(m)|0)-a)).join


Try it online!

# Python 2, 93 bytes

s='s=%r;print"".join(chr(128-ord(i))for i in s%%s)';print"".join(chr(128-ord(i))for i in s%s)
`

Try it online!