# The Swap Puzzle Activity

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.

• 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:

1. Move left or right to an adjacent empty square
2. 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