Hacker News new | past | comments | ask | show | jobs | submit login

The compression is basic run-length encoding, leveraging the Perl repetition operator (x), and the property of the Perl print/say functions that they concat items passed in a list before writing to STDOUT.

https://en.wikipedia.org/wiki/Run-length_encoding

https://perldoc.perl.org/perlop.html#Multiplicative-Operator...

https://perldoc.perl.org/functions/say.html

https://perldoc.perl.org/functions/print.html




I tried xz -9 on it and found, to my surprise, that it was actually longer than RLE!

Then I tried gzip -9, because perhaps that has a smaller header? Yup, saved a few bytes, now it's about the same size. Finally, I remembered that bzip2 does a lot better on text than gzip, and who knows, it might also have a shorter header than xz. Again, a few more bytes saved! Down to 223, where the original is 249 bytes (including the 'say' part but excluding the unnecessary delimiting apostrophes or the rest of the command).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: