โ–ถ Play now

Logic ยท Every game

Line Them Up: a Sorting Algorithm

Put the towers in order, shortest first. The only move is to swap two that stand next to each other.

โ–ถ Play this game

What it teaches

Sorting, and the fact that it can be done with one repeated move. Swapping neighbours is bubble sort performed by hand, and a child who does it a few times has done a real algorithm before ever meeting the word.

The screen says how few swaps the row needs, and that number is exact: the fewest swaps any sorting can take is the number of pairs that start out the wrong way round.

How it works

A row of towers appears, each one as tall as its number. Tap two that stand next to each other to swap them. A tap on two that are not neighbours is refused and says why.

The Watch button runs bubble sort in front of the child, a step at a time: the pair being looked at goes one colour, and the pair it decided to swap goes another, because looking is not swapping and that difference is the algorithm. A fresh row is dealt afterwards, so the answer to the solved one is worth nothing.

What to look for

Four towers is a puzzle and seven is a genuine one. The counter showing how many pairs are still out of order is the thing to point at: it goes down by exactly one on every useful swap, and not at all on a wasted one.

โ–ถ Play this game