digtools
🔢
hit-and-blow,

Bulls and Cows (Hit and Blow) – Number Guessing Game & Solver

A code-breaking game: find the hidden code from the bulls and cows each guess returns.Play solo or with a friend, or let the solver help with a game you're playing elsewhere.

🧩
5 ways to play
Solo, two players, computer guesses, solver and a daily puzzle
🎨
Digits or colors, length 3–5
With or without repeats. The color version uses 6 colors
🔍
Counts what's left
Possible codes, the full list and a suggested next guess

Settings

Code
Length
Repeats

Changing a setting restarts the current games and clears the solver.

Codes, guesses and notes stay on this page. Nothing is saved or sent (only the settings go into the URL).

about,

About

Bulls and Cows (also called Hit and Blow) is a code-breaking game. Every guess tells you how many symbols are right and in the right place (bulls) and how many are right but in the wrong place (cows). On this page you can crack the computer's code on your own, play against a friend on one device, let the computer crack a code you have in mind, or try the daily puzzle that is the same for everyone.

Besides digits (0–9) there is a color version with 6 colors. Choose a length of 3 to 5 and whether symbols may repeat. The solver takes the guesses and results from a game you are playing elsewhere, counts every code that still fits, lists them and suggests a good next guess.

All scoring and counting runs in your browser. Codes, guesses and notes are never saved or sent. No sign-up needed.

how to,

How to use

STEP 1

Pick a mode and settings

Choose a tab, then digits or colors, a length of 3–5 and whether repeats are allowed. The daily puzzle is always digits, length 4, no repeats.

STEP 2

Enter a guess

Tap the digit or color keys and press Enter. You can also type digits and press Enter on a keyboard.

STEP 3

Narrow it down

Use the bulls and cows to rule codes out. The notes and the count of possible codes help you think.

rules,

Rules and scoring

The code is a row of 3 to 5 symbols: digits 0–9, or the six colors red, orange, yellow, green, blue and purple. With no repeats, each symbol appears at most once. A code may start with 0 (with 4 digits and no repeats there are 10×9×8×7 = 5,040 codes).

Code Guess Result Why
7412 0123 0 bulls, 2 cows 1 and 2 are in the code but in other places
7412 1470 1 bulls, 2 cows 4 is in the right place; 1 and 7 are in other places
7412 4712 2 bulls, 2 cows 1 and 2 are in place; 4 and 7 are swapped
1234 1354 2 bulls, 1 cows 1 and 4 are in place; 3 is in another place
0011 0001 3 bulls, 0 cows (repeats) Three are in place. The third 0 in the guess doesn't count: the code has only two 0s

With repeats, add up, for each symbol, the smaller of its count in the code and its count in the guess. That total is bulls plus cows (the scoring used in color code-breaking board games; Knuth 1976–77).

"Length − 1 bulls and 1 cow" (3 bulls 1 cow with 4 symbols) can never happen: the one remaining symbol has nowhere else to go.

tips,

Tips and average guesses

First guess: with no repeats, start with distinct digits such as 0123. Any such guess tells you the same amount, so the real choices start with guess two. If 0123 scores 0 bulls 0 cows, the code uses only the other six digits (360 codes).

Narrowing down: bulls + cows tells you which symbols are in the code, bulls tell you where. Mark symbols ○ or × in the notes and pick guesses that cut the number of possible codes.

How many guesses this page's computer (computer guesses mode and the solver's suggestion) needs over every possible code (computed for all codes on 2026-10-30).

Settings Codes Average Max
Digits, 3, no repeats 720 5.07 6
Digits, 3, repeats 1,000 5.46 7
Digits, 4, no repeats 5,040 5.25 8
Colors, 4, no repeats 360 4.05 6
Colors, 4, repeats 1,296 4.45 5
Colors, 5, no repeats 720 4.83 7

For 4 digits with no repeats, an exhaustive study found that even the strategy with the lowest average needs about 5.21 guesses on average and at most 7 (Tetsuro Tanaka, "An optimal MOO strategy", 1996).

glossary,

Glossary

Bull
A symbol that is right and in the right place.
Cow
A symbol that is in the code but in a different place.
Repeats
Whether a symbol may appear more than once. 4 digits: 5,040 codes without repeats, 10,000 with repeats.
Length
How many symbols the code has; 3 to 5 here.
Possible codes
Codes that fit every guess and result so far. This page checks every code.
Notes
Marks for each symbol: in the code (○) or not (×).
Solver
This page's feature that lists possible codes and suggests a guess from a game played elsewhere.
Suggested guess
The guess that leaves the fewest possible codes on average.
Contradiction
Results that no code can match, usually caused by a wrong answer or a typo.
Hit and Blow (MOO)
Other names for the game. In Japan it is known as Hit and Blow; "hit" is a bull and "blow" is a cow.
faq,

FAQ

Q. What is Bulls and Cows?
A code-breaking game: guess a hidden code (3 to 5 symbols here). Each guess returns bulls (right symbol, right place) and cows (right symbol, wrong place). Fewer guesses wins.
Q. How are bulls and cows counted?
If the code is 7412 and the guess is 1470, the 4 is in the right place (1 bull) and the 1 and 7 are in the code but elsewhere (2 cows).
Q. How does scoring work with repeats?
For each symbol, only the smaller of its count in the code and in the guess counts. Code 0011 and guess 0001 give 3 bulls; the third 0 in the guess does not count because the code has only two 0s, so 0 cows.
Q. Can a code start with 0?
Yes. Codes such as 0123 are allowed (5,040 codes with 4 digits and no repeats).
Q. How many guesses does it take on average?
For 4 digits with no repeats, an exhaustive study showed the best average is about 5.21 guesses, with at most 7 (Tetsuro Tanaka, 1996). This page's computer averages 5.25 guesses over all 5,040 codes, at most 8 (computed on 2026-10-30).
Q. What is a good first guess?
With no repeats, any guess of distinct digits such as 0123. They all tell you the same amount, so the real choices start with the second guess.
Q. How does the solver pick its suggestion?
It counts every code that fits, splits them by the result each guess would return, and suggests the guess that leaves the fewest codes on average (preferring a possible code when tied).
Q. What if I give a wrong answer in computer-guesses mode?
You'll be told as soon as no code fits. Undo to answer again, or enter your real code to see which answer was wrong.
Q. In two-player mode, can the other player see my code?
The screen is hidden after you set your code and whenever you pass the device. The guessing screen shows only your own guesses; both codes appear on the result screen.
Q. What is the daily puzzle?
A code that is the same for everyone on a given date (digits, length 4, no repeats). It changes at 00:00 UTC. The code is not in the URL.
Q. How does the color version work?
The code is a row of the colors red, orange, yellow, green, blue and purple. Scoring is the same as with digits. Turn on repeats to allow a color more than once.
Q. Are my codes or guesses saved or sent?
No. All scoring and counting runs in your browser. Only the mode and settings (digits or colors, length, repeats, show count) go into the URL.
use cases,

Use cases

🏠

Play with family on one device

Pass a phone or tablet back and forth; the screen hides between turns

🏫

Classes and clubs

Try the scoring and the idea of narrowing down possible codes together

☕

A daily puzzle in a spare minute

See how few guesses you need for today's code

📱

Stuck in another game

Enter your guesses and results to see what's left and a good next guess

sources,

Sources

Rules, scoring and the published averages were checked against these sources (checked 2026-10-30).

  • 田中哲朗「数当てゲームMOOの最小質問戦略と最強戦略」(GPW96) https://www.tanaka.ecc.u-tokyo.ac.jp/ktanaka/papers/gpw96.pdf
  • Tetsuro Tanaka "The Minimum Strategy and the Strongest Strategy of the Number Guessing Game MOO" https://www.tanaka.ecc.u-tokyo.ac.jp/ktanaka/moo/moo-en.html
  • 情報処理学会誌 Vol.46 No.6(2005)「数当てゲームMOO」 https://www.ipsj.or.jp/07editj/promenade/4606.pdf
  • パソコン甲子園2010 本選 問題01「ヒットアンドブロー」 https://pckoshien.u-aizu.ac.jp/files/2010honsen.pdf
  • D. E. Knuth "The Computer as Master Mind", Journal of Recreational Mathematics 9(1), 1976-77
  • 45mix「ヒットアンドブローゲームのルールと遊び方」 https://45mix.net/hit-and-blow-game/

All Categories

Send Feedback/Request

Send Feedback

Please let us know your thoughts to help us improve the tool.

This is not an input field for the tool

Disclaimer

The tools provided on this site are completely free to use, but please use them at your own risk. We make no guarantees regarding the accuracy, completeness, or safety of any calculation results, conversion results, or generated data. Please be aware that the operator assumes no responsibility for any damages or troubles caused by the use of these tools. Most tools process files and calculations locally in your browser, meaning your inputted data is neither sent to nor stored on our servers.