*Solve a puzzle, coming up with an algorithm that your team can follow faster than anyone else. *

This introduces the idea of the solution to a problem being a set of instructions that allow others to ‘solve’ it with no understanding. Also explores how different algorithms can solve the same problem but may not be equally good – some may be faster.

Learn about:

- algorithms
- computational thinking
- testing
- efficiency

**Activity**

Place small coins heads up on the blue squares and tails up on the red squares. Swap the positions of the Heads for the Tails in as few moves as possible.

There are two ways to move a piece:

- Move left or right to an adjacent empty square
- Jump over a single adjacent piece into an empty space.

It is not good enough to just complete the puzzle. To solve it, you must write down the algorithm: the sequence of instructions so anyone who follows them can complete it. (eg a move might be written “1 <— 0” to mean move the piece on square 0 to square 1).

There are three increasingly larger boards that get harder. Complete the first in 3 moves, the second in 8 moves and the third in 15 moves. Your solution must be fast (ie take as few moves as possible). If your early solutions take more than the above number of moves then keep trying until you find more efficient algorithms.

Once you have a solution algorithm evaluate it – check it really works by following it step by step from the start.

**A bit of computational thinking wisdom**

Harder problems can be made easier by tackling simpler version first, then generalising the solution.

**Resources**

This session comes with linked activity sheets and write-ups that you can download.

The Puzzle Sheet is a single sided, self contained activity. The other resources give more detail or other versions. You can either print the sheet or just draw the boards on paper.

- Puzzle Sheet: The Swap Algorithmic Thinking Puzzle [PDF]
- Activity Booklet: The Swap Puzzle [PDF]
- Slides: The Swap Puzzle [PPT]
- Applet: The online swap puzzle [Sorry this is interactive version is currently out of order]

You may also be interested in our free very big booklet exploring algorithms, and programming concepts using games, puzzles and everyday things.

- Booklet: Computing Without Computers [PDF]

** **