Skip to content

Instantly share code, notes, and snippets.

@ionutfinta
ionutfinta / str_lz77_len.py
Last active May 2, 2022 21:55
A way to compute the length of the LZ77-encoded string if the indexes are base-10 encoded and the alphabet is known.
def LZ77_len(lz77seq, alphabet, window_size=7):
"""
Utility to compute the length (in bits) of the LZ77 sequence.
Description: see A2 of Anthony Cioppa for details on computation.
Parameters:
lz77seq (string) The LZ77 encoded sequence.
alphabet (list) The alphabet of the message (ex: ['a', 'b', 'c', ..., 'z']) (Warning cannot contain digits!)
window_size (int, default=7) The window size. Must be positive.
Returns: