Bulls & Cows

Pencil-and-paper classicPuzzles

A secret code of four different digits. Every guess tells you a little more. How few do you need?

Bulls & Cows

The code is four different digits, like 4071. After each guess, a bull is a right digit in the right place and a cow is a right digit in the wrong place.

Advertisement

How to play Bulls and Cows

The game picks a secret code of four different digits, from 0 to 9. A code may start with 0, so 0352 is allowed, but no digit appears twice. You type a guess of four different digits and get two numbers back:

For example, if the secret is 4071 and you guess 1074, the 0 and the 7 are bulls (right digit, right place), and the 1 and the 4 are cows (in the code, wrong place): 2 bulls, 2 cows. Keep guessing until you get 4 bulls. The fewer guesses, the better. Your best is saved on your device.

Strategy

Good players crack most codes in six or seven guesses. Computer analysis has shown that, with perfect play, every one of the 5,040 possible codes can be found in at most seven guesses.

The history of Bulls and Cows

Bulls and Cows is an old pencil-and-paper game for two players, each writing down a secret number and taking turns to guess the other's. Nobody knows exactly who first played it; it was passed around by word of mouth long before anyone tried to sell it.

It was also one of the first games ever played on computers. Versions called MOO ran on university machines in the late 1960s and early 1970s, where students competed to crack the code in the fewest guesses. In 1970 Mordecai Meirowitz, an Israeli postmaster and telecommunications expert, turned the same idea into a board game with coloured pegs instead of digits: Mastermind, which went on to sell tens of millions of copies.

Frequently asked questions

Can the secret code have repeated digits?

No. All four digits are different, and the same goes for your guesses. The code can start with zero.

What's the difference between a bull and a cow?

A bull is a digit that is in the code and in the correct position. A cow is a digit that is in the code but in a different position. A digit that isn't in the code at all scores nothing.

Is Bulls and Cows the same as Mastermind?

They are close relatives. Mastermind is a 1970 board game version that uses coloured pegs instead of digits and allows repeated colours. Bulls and Cows is the older pencil-and-paper game it grew out of.

What is a good score?

Five or six guesses is very good, seven is solid, and eight or more means there's room to sharpen your deductions. With perfect play no code needs more than seven.

What are the notes for?

The row of digits under the keypad is a scratch pad. Tap a digit once to mark it as ruled out, again to pin it as definitely in the code, and a third time to clear it. It doesn't affect the game.