Are you allowed to use compression tools (e.g. gzip, xz) in your code?

For example, a shell script with:

cat script.sh.gz|gzcat|sh

(25 bytes)

where the content of script.sh.gz is:

ãö}mbhello.sh=顬0CÔ˚
s⁄m¡   Ó¸@YÕZ‘6Sõ2Ò˜¥∞!ŸŒs8;¡Ö!6…¡ûvÂÊ|AeQ¨Yñl‚tòÑ∑4=†Œ(ºˆuñ∏fñBªÁŒUëdkÑ»+,iT8Û"Ù€õfl0w©ˇ"¶E›èÎÏv‚U«Çgm>¥wˆQÏ%5I¬4|H˚@8÷

(166 bytes)

which decompresses to:

echo Hello world!
echo This is a test program.
echo The idea is that it is compressed.
echo But now the programmer doesn't have to worry about program length that much.
echo It's just left to the compression tool.

(214 bytes, which is more than 25+166=191 bytes)

I've seen this (like in an answer to this question, gzip-ing a shell script), but I'm not sure if it is cheating or not.

  • \$\begingroup\$ @allxy I have read the standard loopholes. When I say this, I mean where script.sh.gz and the other file are both files in the same directory. gzcat is a program that is found in the computer on which the program is run. \$\endgroup\$ Commented Apr 30, 2022 at 22:41
  • \$\begingroup\$ Oops, read that as a URL. \$\endgroup\$
    – allxy
    Commented Apr 30, 2022 at 22:41

1 Answer 1


Yes, but the byte count of the decompression code must also be counted

Say you compressed "abcd" using some compression tool to get "Z" and you can use the code decompress "abcd" to decompress it. The decompress bit must count in the byte count.

  • \$\begingroup\$ So, would the above example count as 191 bytes, or would the code size of the gzip executable be counted as well? \$\endgroup\$ Commented Apr 30, 2022 at 18:46
  • 1
    \$\begingroup\$ The code size of the gzip executable is not counted. \$\endgroup\$ Commented Apr 30, 2022 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .