Back to Challenge Set 22

Code Challenge: Compression Picker

Difficulty  

divider

The Brief

What they asked for
We compress every image row the same way and I have a feeling
it is not always helping. Check it for me and tell me when to
bother.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Reuse the run-length encoding from Activity 2.17. You do not need to decode anything here; only measure.
  • Report the ratio, not the sizes. A ratio can be compared across rows of different lengths; a size cannot.
  • Then give a recommendation for each row. The client asked when to bother; a list of ratios does not answer that.
  • Test at least one row that gets bigger. If none of your test rows does, you have not tested the interesting case.
  • In your requirements list: what ratio is your cutoff, and why that number?

Sample Output

Sample Output
a plain sky: ratio 0.10 -> compress it
a horizon: ratio 0.20 -> compress it
dense text: ratio 1.50 -> do not compress this way

All three rows are the same length. What changed is the redundancy, and the third row would cost 50% more space for the privilege of being compressed.


Submit

Your requirements list and your program file, named cc-compression-picker.

Commence Challenge