A magazine where the digital world meets the real world.
On the web
- Home
- Browse by date
- Browse by topic
- Enter the maze
- Follow our blog
- Follow us on Twitter
- Resources for teachers
- Subscribe
In print
What is cs4fn?
- About us
- Contact us
- Partners
- Privacy and cookies
- Copyright and contributions
- Links to other fun sites
- Complete our questionnaire, give us feedback
Search:
Compression Code Puzzles
Big files take a long time to transfer from one place to another. The more data the longer it takes, and the more memory is needed to store the information. We therefore compress files first, creating zip files for example to send. Data on computers is stored as long sequences of characters - ultimately as binary 1s and 0s. The idea with compression is that we use an algorithm to change the way the information is represented so that fewer characters are needed to store exactly the same information.
That involves using special codes. Each common word or phrase is replaced by a shorter sequence of symbols. A long file can be made much shorter if it has lots of similar sequences, just as the message below has been shortened. A second algorithm can then be used to get the original back. We've turned the idea into a puzzle that involves pattern matching patterns from the code book. Can you work out what the original messages were?
For example, given the message
32223111
With codebook:
1 [Da ] 2 [Do ] 3 [De ]
By repeatedly replacing 1s in the message with "Da " from the codebook, 2 with "Do " and 3 with "De ", we would recover the title of the 1980s Police song about abusing words:
De Do Do Do De Da Da Da
Try and solve our compression code puzzles below (notice that entries in the codebook can be compressed too!). Then make up your own from a passage with lots of repetition.
Repeatedly replace the characters in the following compressed messages by those from the corresponding codebook (the characters between the square brackets) to reveal a computing quotation, a computing joke and a poem credited to Augustus De Morgan, the great mathematician and tutor of 'first programmer' Ada Lovelace.
Message 1:
76FB5D 7CCCF0B9D
Codebook 1
0 [... ] 1 [, ] 2 [aim] 3 [approach ] 4 [development).] 5 [fast ] 6 [fire, ] 7 [Ready, ] 8 [software ] 9 [slow ] A [to ] B [(the ] C [21] D [3A84] E [ ] F [2E]
Message 2
C C 46A7B5DF 7GHE9.
Codebook 2
0 [little ] 1 [code] 2 [in the ] 3 [ninety-nine ] 4 [one ] 5 [compile ] 6 [bug] 7 [and ] 8 [s hiding ] 9 [06821] A [ is fixed ... ] B [we ] C [39,] D [it all ] E [ hundred ] F [again,] G [there are] H [ a] I [ fixed ]
Message 3
9JI D8CA 37 JI 35AE 369IB K40F8A G6HK41A 341A 35 8.
Codebook 3
0 [fleas] 1 [still] 2 [have] 3 [and ] 4 [greater 5 [so] 6 [those ] 7 [lesser] 8 [on] 9 [great ] A [,] B [themselvesA in turnA] C [ their backs to bite 'em] D [up] E [ad infinitum.] F [ to go ] G [while ] H [again ] I [0A] J [0 K7 ] K [2 ]