Ministry of Prose: making words work for your business

One in a semi-regular series of ponderings, musings and contemplations on the interaction of words and psychology in business.



Teaching tomorrow's hackers

May 2015

For the past few months I've been teaching at a local school for one afternoon a week. I teach a course I've called "Understanding and programming computers" and it's been challenging (for me) and fun. You can read more about my experiences at this site, where I've been writing about the lessons.

Although that write-up finished last term, the teaching has continued. Last week was one of the best lessons so far, and it happened almost by accident. One of the local supermarket chains gives out animal facts cards with shopping. Children can collect all of these cards, which have interesting facts about wildlife species around the world.

Animal cards

It's also possible to buy a card reader. Swiping one of the cards through this generates the sound made by whichever animal is on the card. It's a neat little extra feature and encourages the children to collect more of the cards. Even for adults it can be interesting. Seriously, when you hear the Common Loon you'll be convinced it's a whale, not a type of duck.

As I was casting about for lesson ideas last week, I noticed the card reader on the kitchen table, along with some spare cards. So I took it into the class, and we spent the next hour reverse-engineering the logic of its operation. Rather than go into the details, here are my post-lesson notes, which I gave to the teacher so she can teach those children who missed the class.

So in summary: the card reader is a computer, input is the cards (which have a barcode on them), output is sound. Reader has a processor and memory containing digital audio of the animals. The barcode represents a number in binary and the processor matches that binary number to the required sound, then plays it.

All computers work with binary information, because their processors contain millions or even billions of tiny switches that can only be on or off, like a light switch. 1 is on, 0 is off.

Base 10 (decimal) has columns going 10000, 1000, 100, 10, 1 (and so on higher to the left). We can represent any number in those columns, eg. 34,601 or 58 or 227.

Base 2 (binary) has columns 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 (and so on higher to the left). We can represent any number this way too, e.g. 10 in binary is 2 in decimal, 10001 in binary is 17 in decimal, etc. Best shown as a table on the whiteboard.

The barcodes on the cards are a fixed number of fat and thin stripes (I think we counted 13 of them). Fat is 1, thin is 0 (could actually be the other way around depending on how the reader was programmed, but for our purposes it doesn't matter).

By comparing lots of the cards I found that they all have two thin stripes on the right and one fat stripe on the left. The two thin stripes go past the card reader's scanner first, and represent 00. The fat stripe goes through last and represents 1. So those are the markers that tell the reader where the start and end of the card is. Which means we can ignore those three 'columns' and instead put the remaining digits into the binary table to work out the actual number for each card.

Given the remaining number of columns (10), the total possible number of stored sounds is 1,024, but only about 200 or so different cards have been released so far. Which means there may be more new cards on the way. Can we 'hack' the reader and find some of those new sounds by testing new numbers with barcodes we create ourselves? Maybe...

The children loved this. Some of them used the binary table to calculate the decimal numbers assigned to each card, and found these were spread all over the place (e.g. 93, 156, 243, 473, 627, 713). Some went off to photocopy existing cards (these worked), some tried to make new cards using pencil marks (these didn't, perhaps due to reflectivity) and some tried with black felt-tip pen (one of these did work).

The lesson ended before we'd managed to extract any new sounds, if indeed there are any new sounds to extract, but it was still a success. If I'd been taught binary like that at school, I'm sure I'd have learned it faster.

As the lesson ended, one of the boys at the back shouted out, "Thanks for teaching us how to hack computers, Alex!"

Luckily that's not really what I did. But I did teach them never to take computers or other machines at face value. Always be curious, as you never know what you might find.

The next blog post will again be about writing and psychology, but I thought this diversion was worth sharing.

Alex Cruickshank is CEO and Chief Wordsmith at Ministry of Prose and thinks the future might be safe hands.

back back to blog index


All content © copyright 2013-2017 Ministry of Prose (ministryofprose.com): reproduction in whole or in part is illegal under international law.

home | blog | about