4 ms·
$ grep '^[a-z]\{5\}$' /usr/share/dict/words | python -c ' > from sys import stdin > from os import write > N = 26 ** 5 > data = bytearray((N+7)//8) >
by syrrim 5y ago
$ grep '^[a-z]\{5\}$' /usr/share/dict/words | python -c '
> from sys import stdin
> from os import write
> N = 26 ** 5
> data = bytearray((N+7)//8)
> for l in stdin:
> b = 0
> for c in l.strip():
> b *= 26
> b += ord(c)-ord("a")
> data[b//8] |= 1<<(b%8)
> write(1, data)
> ' | gzip | wc -c
12126
decompression code costs extra. Though I imagine someone has a small gunzip implementation somewhere.
- JeremyBanks 5y ago
- retrac 5y agoZlib's implementation, at least, requires more working RAM (~40 KB) than the Game Boy has (8 KB). https://github.com/madler/zlib/blob/master/zconf.h https://github.com/madler/zlib/blob/master/zconf.h The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects.
- hinkley 5y agoThis example above is the entire dict file, not the wordle file, so it might be worth looking at this. I'd have to check the version history, but while 15 bits is the default it's also the maximum, and you can go down to 8. Hardware has gotten a lot faster.
- deleted 5y ago[deleted]
- hinkley 5y agoI think you'll find if you use the real dict that your compression numbers are much worse. I got around 25k using a list I hunted up.