Write a lossless encoder/decoder that is able to compress its own source code.
Encodes data provided on the standard input, writes the encoded representation of the data to the standard output.
Decodes data produced by
encode. Reads the encoded data from the standard input, writes the decoded data to standard output. Must perfectly restore the original data.
$ progname encode < /usr/include/stdlib.h > encoded $ progname decode < encoded > decoded $ diff -qs /usr/include/stdlib.h decoded Files /usr/include/stdlib.h and decoded are identical
It must be a real lossless encoder/decoder for all inputs - encoding any data and then decoding it must produce the original data.
If the input is identical to the program's source code, the size of encoded output must be less than the size of the input.
Size of the program's source code + the size of its encoded source code
The program doesn't need to be a general purpose compressor/decompressor. That's why its commands are called encode/decode. It may also use existing tools predating this question.