Our CS4FN Christmas Computing Advent Calendar has now been running for 23 days! That’s one post every single day, matching a computing-themed blog post to the image on the front of the advent calendar. If you’d like to see how well we’ve managed this please scroll to the end where you can find all of our previous Advent Calendar posts.
Today’s picture is of Father Christmas who, we’ll assume, is re-checking his list and packing his sleigh ready for a long flight around the world, where he’ll be collecting cookies as he goes.
As the song implies, he takes particular care over his list checking it twice to make sure there are no mistakes. In that respect he’s a little like computer scientists who put systems in place to make sure that when they send data to someone else that person can tell quickly if it’s arrived correctly. Today’s post is about reducing errors (and trying to avoid introducing errors). (We don’t know what data collection methods Father Christmas used though.)
1. Reducing errors: check digits
Once I’d reached the age of about 12 my parents started to let me go by myself to my friend’s house which was about a 15 minute walk away. When I arrived I would use my friend’s parents’ landline phone (with permission) to “give 3 rings” to my parents. This meant that I rang my parents’ number – but they didn’t answer, instead they let the phone ring three times and then I hung up. That way they knew the call was from me (our pre-agreed code) but no-one was charged to make or receive a call and they knew I’d arrived safely. (Obviously if the phone rang for longer they’d know it was probably from someone else and answer it).
Computer scientists also use an agreed code when sending data to another person or computer over a network – they want to make sure their data arrived safely too. Data is* sent as binary 1s and 0s and sometimes there’s a scrambling error in the transmission resulting in a 1 arriving as a 0, or a 0 arriving as a 1. A neat way to find out if this might have happened is to double-check what it was supposed to be, by using something called a parity bit (parity means ‘equal’) or check digit. This digit is added to each block of data you’re sending and computer scientists came up with this to let you check if the arriving data looks correct.
Here’s how it works
Suppose you want to send a message consisting of the numbers 6, 13, 2 and 12. These numbers can be converted into binary for data transmission: for example 6 in binary is 0110, 13 is 1101, 2 is 0010 and 12 is 1100. In the 5-row table below these are written in black (the top line is 6 and the fourth row is 12 – we’ll come to the red numbers in a moment).
We’ll now add a parity bit to each row, according to a rule, to make them five digits long.
The rule is that if the binary number has an odd number of 0s we even it up by adding another 0. If there’s an even number of 0s we just add a 1.
In the 1st row 0110 has an even number of zeroes so a 1 is added, 1101 has an odd number of zeroes so an extra 0 is added. Once we’ve checked all four rows we end up with a new parity column (shown in red on the right to make it stand out) on the right. We can also add a new parity row at the bottom as well, by doing the same thing for each of the numbers but read as a column. The first column has an even number of zeroes so we add a 1, the next just has one odd zero so we add a 0 there and so on.
We’ve added extra data to be sent, but this redundancy check (the extra info isn’t part of the message itself but helps support it) makes it easier for the person receiving the information to know if it’s OK or where any problem is.
Let’s pretend you’ve just pressed send and your 1s and 0s are winging their way to your friend.
Unfortunately there was a small error in transmission and one of the numbers has ‘flipped’. Will your friend be able to tell which one it is? (Remember they don’t know what your message actually said, they can only see what’s arrived).
Here’s the (slightly scrambled) data that they receive.
They can use the parity bit information to check each row and column. The first row looks fine – two zeroes (even) and the parity bit one says 1 so that’s right. The second row looks wrong though – there’s an even number of zeroes so you’d expect a 1 in the parity bit – but it says 0, so you know there’s a mistake somewhere in row 2, but your friend won’t know where yet. They need to check the columns too.
Column 1 looks good, there are two zeroes and the parity bit says 1 so that’s correct. Column 2 has an even number of zeroes so you’d expect the parity bit to be 1, but it’s 0. So we know the problem is in Row 2 and Column 2. If we look at where they intersect we can see that a 1 has flipped to a 0, shown below in bold and blue. Your friend can correct the data and translate the binary back into the original numbers.
You could try this with a friend or family member. Think up any 4 numbers between 0 (binary 0000) and 15 (binary 1111) then transmit your binary code with one error and see if they can work out which data bit flipped. Or… you can do it as a magic trick with a pack of cards (see the activity at the end).
*are, for the pedants 🙂
Writing together: Clarence ‘Skip’ Ellis – about Clarence Ellis who used his knowledge of computing to bypass parity checks. The company he worked for was running out of punched cards (we’ll look at these in more depth later in the week) which the company’s computer used to store data. He was able to find a way for his colleagues to re-use the cards they already had, without triggering parity check problems – in doing so the payroll program could be run and everyone could get paid.
2. Trying not to introduce errors: when spellcheck goes worng
Another thing Father Christmas needs to do is check that he has the correct names of all the good children he’ll be giving presents to. He might use a spellchecker for this – this is something that reads the words in a document and compares them to a pre-set list. If a word is spelled in an unusual way the computer will alert you and ask if you want to change it to the one in the list or if you want to add it as a new spelling to the list. It would spot that I spelled ‘wrong’ wrongly in the heading for this section and ask if I meant ‘wrong’ instead of ‘worng’.
Find and replace
Sometimes people want to change a word in their document that appears many times. For example you might put TBA (which can mean ‘to be agreed’ or ‘to be arranged’) as a temporary placemarker in a Word document and later decide that every time the document says ‘TBA’ you’d prefer it to say “to be determined” instead. You don’t have to manually delete and retype every single instance of ‘TBA’, you can ‘automate’ the process using the Find and Replace option. Word will then find every ‘TBA’ automatically and change it to ‘to be determined’.
Sometimes this doesn’t go quite as expected.
In the UK the word ‘ass’ just means donkey but in the US it’s a slightly less polite word for bottom. A slightly more polite word might be ‘butt’ so you – being polite – want to make sure that any time the word ‘ass’ appears in a particular document it’s replaced with the word ‘butt’. This is unfortunate though if you happen to be the editor of a book about donkeys, which is now suddenly about bottoms.
It’s much worse if your document talks about your class at school (clbutt?). Or perhaps it’s some homework about the assassination of an American president (buttbuttination?). Or maybe you need a new password (pbuttword), or even a new passport (pbuttport). Your document is now absolute gibberish and you would not pbutt any exams with that. Where’s spellcheck when you need it?
These types of mistakes are not that uncommon, I’ve even done it myself with the addresses of schools where I send copies of our CS4FN magazine to teachers.
I had a column in my address database which said things like UK, U.K. or United Kingdom and I decided I wanted them all to match and say “United Kingdom”. So… I used find and replace and asked my computer to turn every mention of ‘UK’ or ‘U.K.’ into United Kingdom. It worked beautifully… but I didn’t check the other columns.
I discovered my mistake when ‘Luke’ at a school on ‘Duke Road’ didn’t get his copy of the magazine and it was returned to me by the Post Office as the address was unreadable. I then had to correct both Lunited Kingdome’s name and his DUnited Kingdome Road address 😉 Oops.
Here are some other examples
and here’s what happened when someone changed TBA to ‘to be determined’ without noticing that the string of letters also appears in the word basketball.
3. Magic trick activity: parity check with playing cards
You could demonstrate the parity checking (that we did above with 1s and 0s) as a card trick – you just need an assistant and an audience. If you look closely at the pattern of cards in the picture above, and the pattern of 1s and 0s further up in this post you might notice a similarity…
Give a pack of shuffled cards to an audience member and ask them to deal out 16 cards in four rows either face up or face down (their choice). An example is shown in the left of the picture above. Tell them that in a moment you’re going to ask them to turn over a card while you’re not looking and later, you’ll tell them which card they flipped over. Announce that your assistant is going to make it ‘even harder’ by adding an extra column and row (I bet you can see where this is going). Of course, your assistant is adding a parity bit to the rows and columns (but your audience doesn’t know that) – an example is shown in the middle picture above.
Now avert your eyes (or get someone to blindfold you) and ask the audience member to turn over one card from the grid without telling you which. (Example in the picture on the right, above).
When you look at the grid you can quickly work out which one has been turned over, using exactly the same method we used with the 1s and 0s above.
This trick is a variation of one invented by New Zealand computer scientist, Tim Bell, and you can find more information about it and detailed instructions (as well as ideas to make it seem like you’re really a magician) in our free booklet called The Magic of Computer Science: card tricks special. The trick is called ‘The Out of Body Experience‘ and you can find it on pages 24-31 (pages 13 – 16 of the 33 page PDF).
The creation of this post was funded by UKRI, through grant EP/K040251/2 held by Professor Ursula Martin, and forms part of a broader project on the development and impact of computing.
Other picture credits: the card (faces) comes from Wikipedia and the back is by Clker-Free-Vector-Images from Pixabay
4. Previous Advent Calendar posts
CS4FN Advent – Day 1 – Woolly jumpers, knitting and coding (1 December 2021)
CS4FN Advent – Day 2 – Pairs: mittens, gloves, pair programming, magic tricks (2 December 2021)
CS4FN Advent – Day 3 – woolly hat: warming versus cooling (3 December 2021)
CS4FN Advent – Day 4 – Ice skate: detecting neutrinos at the South Pole, figure-skating motion capture, Frozen and a puzzle (4 December 2021)
CS4FN Advent – Day 5 – snowman: analog hydraulic computers (aka water computers), digital compression, and a puzzle (5 December 2021)
CS4FN Advent – Day 6 – patterned bauble: tracing patterns in computing – printed circuit boards, spotting links and a puzzle for tourists (6 December 2021)
CS4FN Advent – Day 7 – Computing for the birds: dawn chorus, birds as data carriers and a Google April Fool (plus a puzzle!) (7 December 2021)
CS4FN Advent – Day 8: gifts, and wrapping – Tim Berners-Lee, black boxes and another computing puzzle (8 December 2021)
CS4FN Advent – Day 9: gingerbread man – computing and ‘food’ (cookies, spam!), and a puzzle (9 December 2021)
CS4FN Advent – Day 10: Holly, Ivy and Alexa – chatbots and the useful skill of file management. Plus win at noughts and crosses – (10 December 2021)
CS4FN Advent – Day 11: the proof of the pudding… mathematical proof (11 December 2021)
CS4FN Advent – Day 12: Computer Memory – Molecules and Memristors – (12 December 2021)
CS4FN Advent – Day 13: snowflakes – six-sided symmetry, hexahexaflexagons and finite state machines in computing (13 December 2021)
CS4FN Advent – Day 14 – Why is your internet so slow + a festive kriss-kross puzzle (14 December 2021)
CS4FN Advent – Day 15 – a candle: optical fibre, optical illusions (15 December 2021)
CS4FN Advent – Day 16: candy cane or walking aid: designing for everyone, human computer interaction (16 December 2021)
CS4FN Advent – Day 17: reindeer and pocket switching (17 December 2021)
CS4FN Advent – Day 18: cracker or hacker? Cyber security(18 December 2021)
CS4FN Advent – Day 19: jingle bells or warning bells? Avoiding computer scams (19 December 2021)
CS4FN Advent – Day 20: where’s it @? Gift tags and internet addresses (20 December 2021)
CS4FN Advent – Day 21: wreaths and rope memory – weave your own space age computer (21 December 2021)
CS4FN Advent – Day 22: stars and celestial navigation (22 December 2021)
CS4FN Advent – Day 23: Father Christmas – checking his list, spotting the errors (23 December 2021) – this post
3 thoughts on “CS4FN Advent – Day 23: Father Christmas – checking his list, spotting the errors”