4
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.
- s:
128 - 115 = 13
. Code point 13 is a carriage return. - o:
128 - 111 = 17
. Code point 17 is "device control 1" - 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 – 2017-09-06T05:10:01.500
3If there is a 256 code point, would the next largest power of two be 256 or 512? – Dennis – 2017-09-06T05:54:02.993
1If the language automatically ends any output with a newline, can that newline be disregarded for the purposes of the challenge? – Luis Mendo – 2017-09-06T10:13:28.840
@Dennis: 256. The complement would be a null byte. – Zach Gates – 2017-09-06T12:44:35.250
@LuisMendo: If it's unavoidable, it can be disregarded. – Zach Gates – 2017-09-06T12:45:47.610
2@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 – 2017-09-06T14:50:06.277