The plant team wants tonight's photo of the lettuce bed, but the relay can only carry a short message.
Wren lays out a paper grid of the photo. Each square is a letter: G for a green leaf and W for the white wall.
"Row one is G, G, G, G, W, W, W, G," Comet reads. "That is eight letters for one row."
"What do you notice about those letters?" Wren asks.
Comet grins. "They come in runs. Four G, then three W, then one G."
Nova blinks approvingly. "Then send the runs, not the letters," she says. "And check that the team can rebuild the exact row."
Comet grabs a pencil. "Let's build it."
You will compress a paper photo with a run-length code. This is the crew's classroom code for the lab.
A run is a group of the same letter in a row. The code writes how long each run is, then the letter.
So G G G G W W W G becomes 4G 3W 1G. That is 6 symbols instead of 8.
| Lettuce photo | Squares 1 to 8 |
|---|---|
| Row 1 | G G G G W W W G |
| Row 2 | G G G G G G G G |
| Row 3 | W W W W W W W W |
| Row 4 | G W G W G W G W |
Row 4 got longer, not shorter. Compression depends on redundancy, and row 4 has none.
This code is lossless. If your partner followed the codes, their grid matches yours exactly.
The relay is even slower tonight. The crew tries a lossy shortcut of its own.
Rule: if a run is only one square long, paint it the same letter as the run before it.
So row 1, 4G 3W 1G, becomes 4G 4W. That is 4 symbols, but the last leaf is gone.
| What the lab shows | True or false? |
|---|---|
| The run-length code rebuilds the exact grid. | ? |
| The lossy shortcut rebuilds the exact grid. | ? |
| A row with no repetition can get longer when coded. | ? |
| The lossy shortcut lost the single leaf at the end of row 1. | ? |
Great lab work. Tomorrow you will grow a whole tomato plant inside a simulation.