Project: File Compression
Even though storage devices continue to become larger, file compression re-
mains an important tool for everyday computer use. For example, images are
often compressed to enable faster transmission across a network or storage on
a mobile device.
A simple compression algorithm (see, e.g., [3]) for text files is based on en-
coding long strings of repeated characters. The idea is to replace a string of
repeated characters:
!!!!!!!!
with an escape sequence made up of an otherwise rare character (such as ~),
the count, and then the repeated character:
~8!
This saves space as soon as there are at least four in a row of any character. ...

Get A Concise Introduction to Programming in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.