Worked example · Computer Science · Year 7
DCF: Data and computational thinking → Problem-solving and modelling
A completed Year 7 sheet, plus the full code for all 26 letters so you can mark any bracelet in the room in seconds. The scheme is: letter position in the alphabet (A = 1 … Z = 26), written in five binary digits with place values 16, 8, 4, 2, 1. A dark bead is a 1. Show this after pupils have designed their own bracelet.
| Letter | Number | 5-bit code | Working |
|---|---|---|---|
| A | 1 | 00001 | 1 = 1 |
| G | 7 | 00111 | 4 + 2 + 1 = 7 |
| L | 12 | 01100 | 8 + 4 = 12 |
| S | 19 | 10011 | 16 + 2 + 1 = 19 |
| Z | 26 | 11010 | 16 + 8 + 2 = 26 |
| T | 20 | 10100 | 16 + 4 = 20, so it is letter 20, T |
| F | 6 | 00110 | 4 + 2 = 6, so it is letter 6, F |
The two bottom rows go backwards: 10100 has dark beads worth 16 and 4, so 16 + 4 = 20, and letter 20 is T. 00110 has dark beads worth 4 and 2, so 4 + 2 = 6, and letter 6 is F.
Place-value working shown both ways round, letter to bits and bits to letter — first and second success criteria.
| Letter | Beads | Adding the dark beads | Number | Letter |
|---|---|---|---|---|
| 1st | 00101 | 4 + 1 = 5 | 5 | E |
| 2nd | 10010 | 16 + 2 = 18 | 18 | R |
| 3rd | 11001 | 16 + 8 + 1 = 25 | 25 | Y |
| 4th | 10010 | 16 + 2 = 18 | 18 | R |
| 5th | 01001 | 8 + 1 = 9 | 9 | I |
The word is ERYRI — the Welsh name for Snowdonia. The giveaway was that the 2nd and 4th letters have exactly the same bead pattern, so they had to be the same letter.
Decodes a pattern somebody else made, and uses a property of the code (repeated patterns mean repeated letters) as a strategy.
| Letter | Number | 5-bit code | Working |
|---|---|---|---|
| C | 3 | 00011 | 2 + 1 = 3. 16, 8 and 4 are all bigger than 3, so those beads are light. |
| Y | 25 | 11001 | 16 + 8 = 24, then 4 and 2 are too big for the 1 that is left, so 16 + 8 + 1 = 25. |
| M | 13 | 01101 | 16 is too big, so 8 + 4 = 12, then 2 is too big, then + 1 = 13. |
| R | 18 | 10010 | 16 fits, leaving 2. 8 and 4 are too big, 2 fits exactly, so 16 + 2 = 18. |
| U | 21 | 10101 | 16 fits, leaving 5. 8 too big, 4 fits leaving 1, 2 too big, 1 fits: 16 + 4 + 1 = 21. |
My partner decoded it as CYMRU without being told, so the bracelet is correct.
The bracelet is drawn and then tested by a partner, which is the only way to know a code works — third success criterion.
1. 32. Each bead can be one of two colours, so five beads give 2 × 2 × 2 × 2 × 2 = 2⁵ = 32 different patterns.
2. The largest number is 31, from the pattern 11111: 16 + 8 + 4 + 2 + 1 = 31. Note that 32 patterns but a largest value of 31 is not a mistake — one of the patterns, 00000, stands for 0.
3. Four beads only give 2⁴ = 16 patterns, and the alphabet needs 26. Ten letters would have no code at all, or two letters would have to share one, and then nobody could tell which was meant.
4. 32 patterns minus 26 letters leaves 6 spare (including 00000). You could use them for a space, a full stop, a comma, a question mark, and a marker for "the next letter is a capital". A space is the important one: without it the bracelet is one long word.
Counts the patterns from the doubling rule rather than by listing, and explains why 4 beads fail — fourth success criterion.
If I just thread 25 beads with nothing between them, the person decoding has to know that the letters are five beads long — and if they miscount once, every letter after that comes out wrong. That is why I put a thin red divider bead after each letter. Real computers do the same job by fixing the length: every character is exactly 8 bits, so the machine always knows where one ends and the next starts.
Spots that a code needs framing as well as symbols — fifth success criterion.
Place values are 128, 64, 32, 16, 8, 4, 2, 1.
Capital C is 67: 64 fits, leaving 3; 32, 16, 8 and 4 are all too big; 2 fits, leaving 1; 1 fits. So 64 + 2 + 1 = 67 and the code is 01000011.
Capital Y is 89: 64 fits, leaving 25; 32 too big; 16 fits, leaving 9; 8 fits, leaving 1; 4 and 2 too big; 1 fits. So 64 + 16 + 8 + 1 = 89 and the code is 01011001.
8 bits give 2⁸ = 256 patterns. A computer needs them for lower-case letters, the digits 0 to 9, punctuation, the space, symbols such as £ and @, and invisible control characters such as "new line" — none of which a 26-letter bracelet can show.
Extends the same place-value method to a longer code and justifies why the extra length is needed.
| L | No. | Code | L | No. | Code | L | No. | Code | L | No. | Code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| A | 1 | 00001 | H | 8 | 01000 | O | 15 | 01111 | V | 22 | 10110 |
| B | 2 | 00010 | I | 9 | 01001 | P | 16 | 10000 | W | 23 | 10111 |
| C | 3 | 00011 | J | 10 | 01010 | Q | 17 | 10001 | X | 24 | 11000 |
| D | 4 | 00100 | K | 11 | 01011 | R | 18 | 10010 | Y | 25 | 11001 |
| E | 5 | 00101 | L | 12 | 01100 | S | 19 | 10011 | Z | 26 | 11010 |
| F | 6 | 00110 | M | 13 | 01101 | T | 20 | 10100 | |||
| G | 7 | 00111 | N | 14 | 01110 | U | 21 | 10101 |
To check any bracelet: read the dark beads left to right as 16, 8, 4, 2, 1, add them up, and count that far into the alphabet.