Skip to main content

Bulls and Cows

Number of digits

Guess a 4-digit number with no repeated digits (0 can come first).

History

Your guesses and results will be listed here.

Notes

Tap a digit to cross it out (not in the answer), tap again to mark it (in the answer), and once more to clear.

Bulls and Cows (also called Cows and Bulls) is the classic number guessing game. The computer picks a secret number with no repeated digits; after each guess you are told how many bulls (right digit in the right place) and cows (right digit in the wrong place) you have. Get all bulls to win. No download and no sign-up, it works on phones and computers, and you can guess as many times as you like. Pick 5 digits for a challenge or 3 digits for a quick game.


How to play​

  1. Choose the number of digits (4 by default). The computer picks a secret number.
  2. Type a number with no repeated digits and press Guess or Enter.
  3. Read the bulls and cows, use the notes to cross out or mark digits, and keep going until you get every digit right. Stuck? Press "Give up and show the answer", then "New game".

Bulls and cows explained​

  • Bull: the right digit in the right place.
  • Cow: the right digit in the wrong place.
  • Any digit that is neither a bull nor a cow is not in the secret number.

For example, if the secret number is 1234:

GuessResultWhy
1325Bulls 1 · Cows 21 is in the right place; 3 and 2 are in the number but in the wrong places; 5 is not
1243Bulls 2 · Cows 21 and 2 are in place; 4 and 3 are in the wrong places
4321Bulls 0 · Cows 4all four digits are right, all in the wrong places
5678Bulls 0 · Cows 0none of the four digits are in the number
1234Bulls 4 · Cows 0solved

Strategy​

  1. Find the digits first: guess 1234, then 5678. Add up the bulls and cows from both guesses to see how many of the digits 1 to 8 are in the secret number; the rest must come from 0 and 9.
  2. Then find the places: once you know the digits, move them around and watch the bulls. When a cow turns into a bull, that digit has found its place.
  3. Use the notes: cross out every digit from a "Bulls 0 · Cows 0" guess, and tap twice to mark digits you know are in the number.

With 4 different digits there are 5,040 possible secret numbers (10×9×8×7). According to research by Tetsuro Tanaka at the University of Tokyo (The Minimum Strategy and the Strongest Strategy of the Number Guessing Game MOO), the best strategy can solve any of them in 7 guesses or fewer, about 5.21 guesses on average.

Where the game comes from​

Bulls and Cows started as a pen-and-paper game for two players: each writes down a secret number and they take turns guessing the other's. Early computer versions were known as MOO. The board game Mastermind works the same way but uses colored pegs instead of digits. In Taiwan the game is called 1A2B, after the way results are written there.

FAQ​

What do bulls and cows mean?​

A bull is a digit that is in the secret number and in the right place. A cow is a digit that is in the secret number but in a different place. If the secret number is 1234 and you guess 1325, you get 1 bull (the 1) and 2 cows (the 3 and the 2); the 5 is not in the number.

What does 0 bulls and 0 cows tell me?​

None of the digits you guessed are in the secret number. With 4 digits that rules out four digits at once, which is very useful: cross them all out in the notes.

What is the best first guess?​

Any first guess is as good as another, so most players start with 1234 and then 5678. The bulls and cows from those two guesses tell you how many of the digits 1 to 8 are in the number, and the rest must be 0 or 9.

What is the fewest number of guesses needed?​

With 4 different digits there are 5,040 possible numbers. Research by Tetsuro Tanaka at the University of Tokyo found that the best strategy solves any of them in 7 guesses or fewer, about 5.21 guesses on average.

Can digits repeat, and can the number start with 0?​

In this game all digits are different, in the secret number and in your guesses. The number can start with 0, so 0718 is a valid secret number.

How is Bulls and Cows different from Mastermind?​

Both are code-breaking games with the same kind of clues. Bulls and Cows uses the digits 0 to 9 with no repeats; Mastermind is a board game with colored pegs, colors can repeat, and the clues are given with small black and white pegs.