Challenge
Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive palindromes. The best compression with the smallest source wins.
Scoring
total_bytes_saved / sqrt(program_size)
- Highest score wins
total_bytes_saved
is how many bytes smaller the compressed strings are than the originals, total across the test cases below. program_size
is the size in bytes of the source code of both the compression and decompression programs. Code shared between the two need only be counted once.
For instance, if there are 10 test cases and a 100 byte program saved 5 bytes on 7 test cases, 10 each on 2 of them, but the last test case was 2 bytes longer, the solution would score 5.3. ((7 * 5 + 10 * 2 - 2) / sqrt(100) = 5.3
)
Test Cases
tacocat
toohottohoot
todderasesareddot
amanaplanacanalpanama
wasitacaroracatisaw?
Bob
IManAmRegalAGermanAmI
DogeeseseeGod
A Santa at NASA
Go hang a salami! I'm a lasagna hog.
Rules
- Standard loopholes apply.
- The compression must work on all printable ASCII (bytes 32-126, inclusive) text strings, not just palindromes. It doesn't actually have to save space for any inputs, however.
- Output can be any sequence of bytes or characters, regardless of its implementation or internal representation (strings, lists, and arrays are all fair game, for instance). If encoding to UTF-8, count bytes, not characters. Wide strings (e.g. UTF-16 or UTF-32) are not allowed unless the only codepoints possibly used are between 0 and 255.
- Compression/Decompression builtins are not allowed.
For the sake of our own enjoyment, post the compressed strings with your source code.
UPDATE 1: Scoring changed from total_bytes_saved / program_size
to total_bytes_saved / sqrt(program_size)
in order to give more weight to better compression and less weight to aggressive golfing. Adjust your scores accordingly.
UPDATE 2: fixed wasitacaroraratisaw?
to be wasitacaroracatisaw?
wasitacaroraratisaw?
is a counterexample to that \$\endgroup\$[32-126]
? \$\endgroup\$1000 *
part is really needed, and no I don't think it will make the score feel more "satisfying" ;) \$\endgroup\$