N-ary run length encoding

Juan Francisco Rodríguez Herrera
Vicente González Ruiz

September 12, 2016

Contents

1 Intro
2 Compressor
3 Decompressor

1 Intro

2 Compressor

  1. While there are symbols to encode:
    1. Let s the next symbol.
    2. Read the next n consecutive symbols equal to s.
    3. Write the pair ns.

3 Decompressor

  1. While there are ns pairs to decode:
    1. Write n-times the symbol s.

Example

The runs:

aaaabbbbbaaaaaabbbbbbbcccccc

are encoded as:

4a 5b 6a 7b 6c