How to guess the number in 5–7 moves
In Bulls and Cows, luck matters less than it seems. A good move does not have to hit the right digits, but it sharply cuts the list of numbers that could still be the answer. The figures below come from our bot: it has played all 5040 possible numbers.
How many moves the bot needs
On average the bot needs 5.27 moves. It solves 61% of numbers in five moves or fewer, 98% in six, and never takes more than 7.
| Moves | Numbers | Share |
|---|---|---|
| 1 | 1 | under 0.1% |
| 2 | 4 | under 0.1% |
| 3 | 59 | 1.2% |
| 4 | 574 | 11.4% |
| 5 | 2430 | 48.2% |
| 6 | 1885 | 37.4% |
| 7 | 87 | 1.7% |
For comparison: an exhaustive computer search of all strategies shows that no strategy can average better than 5.21 moves. The bot is less than a tenth of a move behind the ideal, and its logic fits in one sentence.
The main idea: split the options evenly
Every answer splits the remaining numbers into groups. If almost all options give the same answer, the move tells you almost nothing. If the groups are about equal, few options remain whatever the answer. On every move the bot tries all 5040 numbers and picks the one that leaves the fewest candidates on average. The move review marks the best moves by the same logic.
The first move
While nothing is known, all first moves are equally good: any number turns into 0123 by simply relabeling the digits. After the first move, about 931 options remain on average. Here is how the answers to 0123 are distributed:
| Answer | Numbers |
|---|---|
| 0 bulls, 1 cow | 1440 |
| 0 bulls, 2 cows | 1260 |
| 1 bull, 1 cow | 720 |
| 1 bull, 0 cows | 480 |
| 0 bulls, 0 cows | 360 |
| 0 bulls, 3 cows | 264 |
| 1 bull, 2 cows | 216 |
| 2 bulls, 0 cows | 180 |
| 2 bulls, 1 cow | 72 |
| 3 bulls, 0 cows | 24 |
| 0 bulls, 4 cows | 9 |
| 1 bull, 3 cows | 8 |
| 2 bulls, 2 cows | 6 |
| 4 bulls, 0 cows | 1 |
Most often the answer is one or two cows. The answer “0 bulls, 0 cows” is actually a lucky one: it removes four digits at once, leaving 360 numbers.
The second and third moves
- Use new digits. A second move like 4567 is usually more useful than rearranging the same 0123: it tells you how many secret digits hide among the other four, and so also in the remaining pair, 8 and 9.
- Mix old and new. When you know that two of 0123 are in the number, a move with two old and two new digits helps find out which ones.
- Do not avoid moves that cannot be the answer. Sometimes a number that clearly does not fit the earlier answers splits the options better than any that does. The bot does exactly that.
Positions matter more than digits
Once the set of digits is clear, only the order is left: four digits can be arranged in 24 ways. Remember that a move with no bulls says something about positions too: none of its digits is in its place. That rules out some arrangements at once, and often only two or three moves remain.
Write down what you learn
Cross out the digits that are definitely out, mark the ones that are definitely in, and work out which one could go where: that is what the notebook is for. And you can practice without risking your streak in practice mode.