Game Boy Wordle clone: How to compress 12972 five-letter words to 17871 bytes
Like y&#x27;all, I wanted to see how I could do. Of course, I didn&#x27;t get all the way to tested code on a gameboy. But it does compress &amp; decompress in Python.<p>I took the central idea of encoding deltas (or actually delta less 1, since the delta is always at least one; I&#x27;ll just say delta below), but did it on the full five letter word. The largest delta was still less than 2*18 but bigger than 2*17. (I&#x27;m not sure why the blog mentions 20 bits as the biggest delta; I used the dataset from <a href="https:&#x2F;&#x2F;github.com&#x2F;alex1770&#x2F;wordle&#x2F;commit&#x2F;62520406365ca58a1a30d398a2bfad8666f6c3c4" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alex1770&#x2F;wordle&#x2F;commit&#x2F;62520406365ca58a1a...</a>)<p>I decided I wanted a variable length code in bits. Manually, I found the best break-points that I could:<p><pre><code>    breaks = [16, 128, 512, 2**12, 2**18] 
    bitprefixes = [&#x27;0&#x27;, &#x27;10&#x27;, &#x27;110&#x27;, &#x27;1110&#x27;, &#x27;1111&#x27;]
</code></pre>
So deltas 0..15 are encoded as &#x27;0&#x27; plus a 4-bit number, deltas 16..271(=16+256-1) as &#x27;10&#x27; plus a 7-bit number, etc.<p>Compressed like that, my dictionary runs to 14840 bytes.<p><pre><code>    1111000000000001010110 &#x2F;&#x2F; aahed   4839 =    4839-      0
    1110100001101100       &#x2F;&#x2F; aalii   2813 =    7652-   4839
    1110110100010010       &#x2F;&#x2F; aargh   4003 =   11655-   7652
    110011000010           &#x2F;&#x2F; aarti    339 =   11994-  11655
    1111000000001101110001 &#x2F;&#x2F; abaca   5634 =   17628-  11994
    00111                  &#x2F;&#x2F; abaci      8 =   17636-  17628
    00001                  &#x2F;&#x2F; aback      2 =   17638-  17636
    00111                  &#x2F;&#x2F; abacs      8 =   17646-  17638
    100111110              &#x2F;&#x2F; abaft     79 =   17725-  17646
    ...
</code></pre>
However, a non byte aligned code isn&#x27;t ideal, especially on the gameboy&#x27;s CPU which doesn&#x27;t have variable bit shifts as far as I recall. Still, over 3000 bytes beckoning to be re-used for some other purpose. Did they put in a soundtrack yet?<p>Compressor &amp; decompressor: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;jepler&#x2F;d502965b57fd52df0838a6def2d32a0c" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jepler&#x2F;d502965b57fd52df0838a6def2d32...</a>