Practice code-breaking logic on Mastermind
Six colours, four positions, twelve guesses — every guess returns black and white pegs. The classic deduction puzzle, solvable every time.
Tools used in this guide
The job
A hidden code of four coloured pegs; you guess, it answers. Black pegs mean right colour right spot, white means right colour wrong spot. The entire game is information management: each guess should be chosen to halve the remaining possibilities.
Guess, read, narrow
Click colours into the four slots and submit. Pegs count matches without positions — a code with two reds scores guesses containing reds accordingly. Twelve guesses is generous; the published strategy solves in five.
- Repeats are allowed — the code can be four greens, and so can your guess.
- Knuth's five-guess algorithm exists; the human version is to always play a guess consistent with every answer so far.
Reading the pegs
Black counts first, then white counts leftover matches — 'red in slot 1' can't score twice. The peg order tells you nothing about which positions matched; that's information you extract across guesses, not within one.