Program - run-length encoding of black & white pixels for Raspberry Pi/Ubuntu PC using GNU C++

last edited Apr 13 2017 by Phil Gardner | Created by Phil Gardner | Other contributors:

Encodes strings composed of 'b' and 'w' characters, compressing contiguous blocks

Solution to the problem described in the Cambridge Elevate GCSE text book.

If you have a Raspberry Pi, you already have the compiler to make the executable. You can load the runlength.cpp file into the Geany editor, then click on Build. Once built successfully, you can click on Execute.

If you are using Ubuntu, if you do not have the compiler, you can install it with…

sudo apt-get install build-essential

To compile from command line using compiler:

g++ runlength.cpp

…then run the executable with:


Deluxe compilation instructions, for an executable with a more descriptive name:

g++ -o runlength runlength.cpp

…run with:

./snow “What’s it got in its pocketsess?” Constants, integer and string data-types, random numbers (not seeded in this case), % (m

Level: (Beginner / Intermediate/ Advanced)

Duration: (duration, if applicable)

Teaches: (set of concepts learned)


By downloading this resource you agree to the CAS resource guidelines and use it appropriately.

Note: Unless otherwise specified, this resource and all associated files are published here under the Creative Commons Attribution-Share Alike 3.0 Licence. If you wish to use a different license, please state this in the description.

Read our resource guidelines

Feedback and Comments

Available when logged in (sign-up, for free):
  • View 0 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.
no image

This resource has attached files: to access these files, please tick the box below to assent to the license terms

License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

It has been downloaded 5 times.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.