Teaching article

A shorter symbol message must still be recoverable

Represent repetition compactly and check that it can be reconstructed.

Five repeated stars can be represented compactly using a count and symbol. Give the decoder the convention and check reconstruction, so the task concerns preserving information rather than merely making the page look shorter.

Five stars can be represented as '5 × star' under the agreed key.

Decode the compressed version back to the original

Include the reconstruction convention alongside the compact message. Shortening a representation is useful only when the intended information can be recovered.

Count repeated symbols. Write count and symbol. Decode the result.

The decoder needs the convention. Is reconstruction exact?

Start with one repeated run.

Resources

Further reading

Read next

Explore Coding and computational thinking. Browse all teaching articles.