Creating puzzle…

Bulls and Cows Online — Free Number Guessing Game

Bulls and Cows is a code-breaking game with numbers, like Mastermind with digits. A number is hidden; after each guess you learn how many digits are in the right place (bulls) and how many are in the number but in the wrong place (cows). Find it in as few guesses as you can.

How to play Bulls and Cows

The secret number has 3, 4 or 5 digits, all different. Any digit from 0 to 9 can be used, and the number may start with 0.

Type a guess with the same number of different digits. The game answers with bulls and cows: a bull is a right digit in the right place, a cow is a right digit in the wrong place. Digits that are not in the number are not counted.

When every digit is in its place (4 bulls in a 4-digit game), you win. Your score is the number of guesses you needed.

An example game

Say the secret number is 4271:

  • 1234 → 1 bull, 2 cows: the 2 is in place, the 1 and the 4 are in the number but elsewhere. So three of 1, 2, 3 and 4 are in it.
  • 5678 → 1 bull: only one of 5 to 8 is in the number, already in place. That makes four digits, so 0 and 9 are out.
  • 4231 → 3 bulls: three digits are in place, and the other one is not in the number.
  • 4271 → 4 bulls: solved in four guesses.

Tips

A few habits make the clues add up faster.

  • Start with guesses that share no digits, such as 0123 and 4567. Together they show how many of the secret’s digits are in each group.
  • A guess with 0 bulls and 0 cows rules out all of its digits at once.
  • Change one or two digits at a time, so you can tell which one changed the score.
  • Turn on Mark digits to mark digits on the keypad as ruled out or in the number; the same digits change colour in your earlier guesses.
  • A computer can always find a 4-digit number in at most 7 guesses, about 5.2 on average.

Daily Challenge

Every day (UTC), everyone gets the same 4-digit number. Press Start when you are ready: the timer runs until you find it, even if you leave the page, and you have up to 30 guesses. The leaderboard ranks the fewest guesses first, then the fastest time. The number is kept on the server, so the page does not know it until you finish.

Other names

The game is also called Cows and Bulls, 1A2B in China and Taiwan, Hit & Blow in Japan and number baseball (숫자야구) in Korea. It was played with pencil and paper long before the board game Mastermind, which uses the same idea with coloured pegs.

Common questions

Can the secret number start with 0?

Yes. As in most versions, 0 can come first, so 0123 is a valid number.

Can digits repeat?

No. The secret number and every guess use different digits.

What is the difference between bulls and cows?

A bull is a right digit in the right place; a cow is a right digit in the wrong place. If the number is 4271 and you guess 1234, the 2 is a bull and the 1 and 4 are cows.

How many guesses does it take?

With 4 digits, most players need 6 to 10. With the best strategy, a computer never needs more than 7.

Is this the same as Mastermind?

It is the same idea with digits instead of colours. Mastermind is a trademark of its owner and is not connected with this site.

Do I need an account for the Daily Challenge?

No. An anonymous cookie remembers your player number; no account or email is needed.