Bulls and Cows solver
Type each guess and its score. The solver shows every code that still fits and the guess that narrows them down fastest. It runs in your browser.
How the solver works
There are 5,040 possible codes: four different digits from 0 to 9. Each score rules out every code that would have scored differently, so the solver keeps only the codes that give every score you entered. Then it tries each of the 5,040 codes as the next guess and picks the one that leaves the fewest codes on average. When two guesses tie, it prefers one that could still be the code, because that guess can win at once.
How good is it?
Start with 1234 and follow the solver, and every one of the 5,040 codes is cracked in 7 guesses or fewer, 5.27 on average. It has been proved that any code can be cracked within seven guesses, and the best possible average is about 5.21 guesses (Wikipedia).
Its best guess is not always a code that could be right. Sometimes a guess that cannot win splits the codes left more evenly, and that saves guesses later.
A worked example
Leo hid the code 7856, the game from the strategy guide. Press Try the example to enter its first three guesses and watch the codes fall away.
| Guess | Score | Codes that fit |
|---|---|---|
1234 | 0/0 | 360 |
5678 | 0/4 | 9 |
7851 | 3/0 | 1: 7856 |
Play fair
Use the solver to study a finished game, to check your thinking in Solo, or to learn why a guess was good. Using it in a match against a person spoils the game for them.
Crack codes yourself
The strategy guide shows how to think like the solver, and the rules of Bulls and Cows explain every score.