Run-length encoding (RLE) is a lossless way of compressing data that has long runs of the same value, such as simple images. Instead of storing every pixel, it stores each run: how many pixels in a row are the same colour, then the colour.
Example: the row WWWBBBBW (3 white, 4 black, 1 white) is stored as 3W 4B 1W: three runs instead of eight pixels. The image can be rebuilt exactly from the runs, so nothing is lost. But each run is two values (a count and a colour), so RLE only saves space when the runs are long: a busy image, where the colour changes often, can need more values than it has pixels.
How to play
- The target image is on the left, with the row to encode highlighted. Your decoded image builds up on the right.
- Type each run from left to right: the count (1 or 2 digits), then the colour letter, which ends the run.
3 then W is 3W. Use the keypad, or the keyboard (digits, W B R G, Backspace).
- When your runs add up to the whole row, it's checked. Right, and the row is painted; the image is done when every row is.
- Two runs of the same colour side by side, or a row that doesn't match, cost 5 seconds, and the feedback shows the right encoding. Each run must be as long as it can be:
2B 3B should be 5B.
You start with 60 seconds. Each row and each image you finish adds time (up to 60), and more points in the bigger and more colourful modes. The clock runs 3% faster for every row you've finished, so it gets harder as you go. The game ends when the time runs out.
Objective: explain how run-length encoding compresses an image without losing data, and encode an image as runs of a count and a colour (for example, Cambridge IGCSE Computer Science 0478, 1.3 data storage and compression; Cambridge International AS & A Level 9618, 1.3 compression).
Where this fits
- AP: AP Computer Science Principles
- AQA: AQA A Level Computer Science (7517)
- Cambridge: Cambridge IGCSE Computer Science (0478); Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618)
- IB: IB Computer Science HL; IB Computer Science SL
- Pearson Edexcel International: Edexcel International GCSE Computer Science (4CP0)
- USDP: USDP Computer Science