Computational thinking unplugged

Paul Curzon

Learn computational thinking skills through real problems, games, puzzles and magic.

Computational Thinking is a set of problem solving skills centered around algorithms. It boils down to seeing the solution to a problem as not the answer itself, but a method that guarantees to give you the answer. Once you have an algorithm, anyone can solve the problem by following the instructions. It is a powerful way of thinking about solving problems that has completely changed the way we live and work, as well as giving new ways to do science and other disciplines too. It even underpins magic! As you learn to be a computer scientist you are learning the same core skill set you need to be a great magician.

As you study computer science and learn to program, you naturally develop computational thinking skills. You can turn this around, however. Programming is easier to learn if you develop computational thinking skills. You can explicitly teach computational thinking. Like any skill, whether riding a bike or juggling, the more you practice the better you get. It also helps if you understand the concepts, and these too can be taught. Unplugged techniques – away from a computer – give powerful ways both to understand the concepts and practice the skills.

Different people have different ideas about what the computational thinking skill set really is, and to what extent it really underpins computing, but the core is clear: ideas such as algorithmic thinking, decomposition, abstraction and generalization matter. Other aspects include logical thinking, evaluation, choosing representations and pattern matching. These skills are not unique to computer scientists of course. They are used widely in different ways by engineers, designers, mathematicians, historians, … computer science itself is derived from many disciplines and whether or not computer scientists can lay claim to the skills hardly matters. It is a generally useful skill set. One thing it is important to remember though is that the aim is to solve problems for people, so understanding people matters too – computer scientists don’t just have to understand computers.

Real problems
cs4fn Let’s look at the idea using a real problem: that of helping people with locked-in syndrome. It is a medical condition where you cannot move at all. You are totally paralyzed for life. You can still see and hear, but cannot speak. You cannot communicate. Your intelligent mind is locked inside a useless body. If lucky, you might blink an eyelid. How might a computer scientist help? Perhaps inventing some new technology? There is something more fundamental: solving the basic problem whether or not technology is involved. That involves computational thinking. Let’s suppose the person concerned can blink one eye. Can we think of a way for them to ‘talk’ to us? How would you do it? You need to come up with a code for blinks. One blink means A, two blinks means B and so on, perhaps. But that takes lots of blinks. Can you come up with a better way with fewer blinks needed? The person they are talking to can go through the alphabet, saying A, B, C and the person blinks when they get to the right letter. The person then writes down that letter. In coming up with the method we are doing algorithmic thinking. We have devised two different algorithms to do the same thing: communicate by blinking. In comparing them we have used abstraction, hiding detail: we decide which is best by thinking just about the number of blinks or number of questions asked, not every detail. Can you come up with even better ways? There are faster algorithms. The key thing is that both people have to agree on the algorithm, but if both follow the agreed steps in the right order, they will communicate successfully.

Try it with a friend. Communicate a message by blinking. As you do, you may realize the algorithm needs some refinement to really work for people. Evaluation matters! For example, you may realize that people can blink when they didn’t mean to. You need a way to say: “No I didn’t mean that letter”. Once you realize the problem you can refine the agreed algorithm. You need ‘Undo’. Perhaps two blinks means go back a letter. Pedantic detail matters too. You have to work out and agree all the detail in advance. Did you think about spaces and punctuation? Digits?

You may also realize you can use reuse ideas from elsewhere. For example, you might guess words before they are finished: predictive texting! Once we realize two distinct problems are the same we can generalize the solution and use the algorithm from one to solve the other. When you are texting, the phone is trying to work out the words you are thinking of, a letter at a time, too. We can work out the best way to do the predictive part largely separately from the basic algorithm: decomposition.

We can perhaps get ideas from other places too, like the game of 20 Questions, where one person thinks of a famous person and the other person has to guess it by asking yes/no questions. Generalized, it is the same problem. Perhaps you can see how to adapt the way you play 20 Questions to give a new solution to communicating with blinks.

In all of this we haven’t been thinking about technology, just algorithms: algorithmic thinking matters even when computers are not involved. We’ve also been thinking about people – how do we make it work for them.

Puzzles
Puzzles are another way to develop computational thinking skills. There are many puzzles that are algorithmic in nature, from swapping the positions of frogs and toads on a line of squares to a Rubik’s cube. Many like Sudoku and Kriss Kross involve logical thinking. Do lots of puzzles to develop the skills. You haven’t solved a puzzle just by getting it out, though. You need to understand in detail how you did it. You need to have a way that guarantees to solve it, so that someone else can blindly follow your instructions and solve it, or any other similar puzzle, too. Puzzles don’t have to be fiendishly difficult. You can develop computational thinking even with simple puzzles. In fact it’s important to start simple and develop the skills before working on hard problems. Otherwise it’s easy to just give up. Anyone can do computational thinking, but you need to develop the skills. You need to practice. Lots!

Take word searches. You can try to do them by randomly looking over the grid, hoping words pop out. Better though to have an algorithm. Think explicitly about how you can guarantee solving it. One way is to take the first letter of the first word. Scan the grid from the top corner working along a cell at a time until you find that letter. Then look at each letter in turn around it to see if it is the second letter of the target word. If it is, then keep checking in that direction. If not, carry on. The core to this can be generalized. To find something, pick an order and check one at a time. We can use it in other situations to search for something. It’s linear search! In fact we used it twice in our word search solving algorithm: to check the second letter too. Variations of how we use it may improve things. For example, we could start by looking for rare letters in the word, rather than the first letter, cutting down the total number of letters checked. Rather than just solving a word search we are doing algorithmic thinking. Come up with a fast way and we can use it to solve any puzzle.

Let’s look at another puzzle: colour by number pixel puzzles. They involve a grid of numbers, with each number representing a colour. Colour them according to the key to reveal a picture. Now think about ways to do them: algorithmic thinking. You could pick a colour and get that pen. Then work from the top corner, a square at a time. Check the number in the square to see if it is your colour. If it is, colour it Move on. We are just doing linear search again! The same algorithm, suitably generalized works for both solving word searches and colour by number pixel puzzles. Again we can think of alternatives. We could look at each square in turn, determine the colour, pick up that pen and colour it in, then move to the next and do the same. That would involve a single scan of the grid instead of one for each colour, so perhaps it is faster. However, it involves picking up and putting down the pen lots, so it depends how quickly that can be done. For a human it is slow. For a printer it is fast, so most printers print images by changing pens as they scan the row. Context matters in computational thinking.

Ladybird-grid

We can explore decomposition too. Suppose we have a big pixel puzzle. It will take a long time to colour. But if we have a whole class, we could cut it into small squares so each has a small, manageable puzzle to do. Of course detail still matters. Think it through before you cut up the picture. Will you be able to put it back together again? It’s a good idea to number the pieces with positions first. Otherwise you will have a jigsaw to solve. Algorithmic thinking again. Computational thinkers think through the detail before they take action!

The digital age is defined by the way we can represent things as numbers to manipulate, store and transmit. Pixel puzzles can be used to discuss representation. Colours are represented by numbers. Images are broken into a grid of pixels so they too can then be represented by numbers. That is essentially how a digital camera stores an image. The more numbers, the higher the resolution and the more accurate the image. Now suppose you want to transmit the image across the room. You can just shout out the numbers. The other person writes them down. Try it and you’ll quickly realize it’s slow. Perhaps you can think of a way of sending fewer numbers but still recreate the picture. When there is a block of colour like six blue pixels in a row (where blue is number 3, say) send a pair of numbers 6 3 instead of 3 3 3 3 3 3. You’ve just invented a compression algorithm and a new representation of images.

Magic
Magic provides a fun, memorable way to introduce computational thinking, the idea of an algorithm, and many other computing concepts. Any magic trick consists of a secret method and a presentation. So does software – an algorithm and an interface. Both matter. One group of tricks called self-working tricks involves no misdirection, hidden technology or sleight of hand. Follow the steps and they just work. A self-working trick is just an algorithm for a magical effect! You can take a self-working card trick (see box), and get someone else to do it, following your instructions step by step. You don’t even need to touch the cards. That demonstrates the essential idea of an algorithm. The person does not have to know what they are doing, never mind how it works, to get the magical effect. That’s why algorithms matter to computer scientists – a computer after all has no idea what it is doing. All it can do is follow its instructions blindly.

Have fun
Magic, games and puzzles give fun ways to explore computational thinking concepts, and to develop the mental toolkit and the skills. Computer scientists are computational thinkers, but you don’t need to just write programs to develop the skills, or to use them.

You can find resources for using the above ideas in class, as well as lots more ideas for teaching computational thinking unplugged from www.teachinglondoncomputing.org.

Are you psychic?

Take two sets of five pairs of identical cards. With the two sets in the same order one after the other, fan the cards face down and ask a member of the audience to touch the back of any card. Split the pack there, putting the top cards to the bottom. Keep doing this until the volunteer is happy they are mixed. Now count the top five cards one at a time face down into a single pile on the table. Place the other five face down in another pile. Now give the volunteer four ‘magic crystals’ (or coins will do). Tell them they must use the power in the crystals to end up with two matching cards but without looking at the cards. Get them to split the crystals between the two piles of cards any way they like. You then do the number of ‘moves’ on a pile as given by the number of crystals there. A move is just to take the top card and put it to the bottom. So if they put two crystals on a pile you move the top two cards from top to bottom. Do it to both piles. You take the top card of each pile, and place them aside putting a crystal on top.

Now do the same again with the remaining cards and crystals. The volunteer splits the remaining crystals be-tween piles. You then do the right number of moves on each pile and put the top two cards aside with a crystal. Keep doing this until only one pair of cards are left. Ask them if they have magic powers. Do they think they have matched the cards? Reveal the last cards to show they have magically matched the cards. Then suggest you want to see how powerful they really are. Check the other pairs. They all match too, despite the volunteer mixing the cards at the start and having a free choice throughout.

Beg your volunteer to stop denying their special powers and start using them for the good of humanity!

The author is a Professor of Computer Science at Queen Mary University of London. He leads cs4fn (www.cs4fn.org) and Teaching London Computing (www.teachinglondoncomputing.org). He is co-author with Peter McOwan of the book ‘The Power of Computational Thinking’. He can be reached at [email protected].

Leave a Reply