Bulls & Cows
A secret code of four different digits. Every guess tells you a little more. How few do you need?
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:
- Bulls: digits that are in the code and in the right position.
- Cows: digits that are in the code but in a different position.
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
- Open with 0123, then 4567. Between them, these two guesses tell you how many of the code's digits are in 0–3, 4–7 and, by subtraction, 8–9.
- A zero is a gift. A guess scoring 0 bulls and 0 cows rules out four digits at once. Strike them out in the notes row.
- Bulls fix positions, cows only digits. When you move one digit and the bull count drops, you have learned where it belongs.
- Change one thing at a time once you know the four digits. Swapping just two positions between guesses makes the feedback easy to read.
- Every guess should be possible. Before you press Guess, check it against every earlier score. A guess that couldn't be the code wastes a turn.
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.