Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input.
In other words, if f
is your program as a function, then f(f(x))=x
for all x
.
Now, since this is a "compressor", it should actually try to compress it's input. Of course, it can't compress every input. It should however be able to compress your program's source code. That is, if s
is your program's source code, then len(f(s))<len(s)
.
To recap, your program acts as a function that takes a list of bytes as input and outputs a list of bytes as output. Let's call your program f
and it's source code s
. Your program must satisfy both:
f(f(x)) = x
for allx
len(f(s)) < len(s)
Remember that the empty list is a list, and thus your code should be able to handle it.
Normal quine rules apply, so no introspection is allowed (opening the file that contains your source code, etc.).
Shortest code wins!