**From New Scientist #1195, 21st February 1980** [link]

The little Buggins were given a games-playing robot for Christmas and are fascinated still. Among its games is a fearsome version of the old Victorian pastime now marketed as Mastermind. The robot thinks of a number and you try and deduce what it is by proposing a series of numbers with the right number of digits. After each guess the robot shows one flashing light (*F*) for each correct digit correctly placed and one steady light (*S*) for each correct digit wrongly placed. Thus, if it chose 98766 and you guessed 66765, it would show *FFS*.

The machine can handle any number of digits up to nine but the Buggins kids are only human and are having trouble enough with five-digit numbers. Here, for instance, is a series of five guesses and the robot’s comments:

1 2 3 4 5 *FFS*
3 1 6 2 0 *SSS*
7 3 8 9 0 *FS*
8 9 5 1 4 *F*
6 0 1 7 1 *FSS*

What do you reckon the robot’s number is?

**Enigma 147** and **Enigma 262** are also called “Think of a number”.

[enigma52]

### Like this:

Like Loading...

My original solution was just to try all candidate 5-digit numbers against the guesses to see if they produced the right scores, but this took a couple of seconds. Here’s a recursive solution that uses the “right digit in the right place” information to test a much reduced set of candidate 5-digit numbers. It runs in 43ms.

Solution:The robot’s number is 72311.