← Home

Mastermind solver

Stuck on a game, on a board or on screen? Copy each of your guesses here with the feedback you got: the solver counts the codes still possible and suggests your next move.

4 pegs, 6 colors, repeats allowed

Add a guess

Black pegs
0
White pegs
0

How to use the solver

  1. Pick the level of your game: the number of pegs, the number of colors and the repeat rule all change the list of possible codes.
  2. Build your guess with the palette, or with the keyboard: keys 1 to 9, then 0 for the tenth color. Backspace removes the last peg, Enter adds the guess.
  3. Enter the feedback you got: one black peg per right color in the right spot, one white peg per right color in the wrong spot.
  4. Repeat after each guess. If you made a mistake, take back the last guess or clear everything.

What the solver works out

It goes through every code of the level and keeps only those that would have given exactly the feedback you entered. It's the reasoning you do in your head, carried all the way through: each piece of feedback rules codes out, and soon only a handful remain.

The safest move is the still-possible code that, in the worst case, leaves the fewest codes behind. Comparing every move takes a lot of computing: as long as more than 600 codes remain, the solver only suggests a code that is still possible, consistent with all your feedback, and says so plainly.

If the solver reports a contradiction

Zero possible codes means no code can produce all the feedback you entered. The cause is almost always a black and a white peg swapped, a color copied wrong or the wrong level, for example Easy instead of Classic when the code holds a repeated color.

Rather work it out yourself? Play Mastermind online, watch the computer crack your code or start with the 2-minute tutorial.