TECHNOLOGY · 4 MIN
How a file gets smaller without losing anything
Compression finds repeats and describes each one once.
How can a zip file be smaller than the original yet unzip perfectly?
Plain English text often zips to about a third of its size.
Describe repeats once
Look for repetition. Twelve letters, AAAAAAAABBBB, can be written as “8 A, 4 B”: four symbols instead of twelve. Zip goes further: whenever a chunk has appeared before, it writes a short note saying “copy those characters from back there.” Language repeats constantly, so text often shrinks to about a third.
Some data won’t shrink
Data that’s already compressed, or truly random, has no repeats left to find. Zipping a zip file barely helps, and can even make it slightly bigger. Photos, music and video use a different trick, lossy compression: they throw away detail your eyes and ears barely notice, and that can’t be undone.
Turn on JavaScript to watch each board draw itself, solve one on your own and explain it back.
More in Technology
See the whole library