Naive implementation of LZ77 compression algorithm