
Brain Games · Logic
4 pegs from 6 colours, no repeats: 360 possible codes. 10 guesses.
In short
Code Breaker is a game of deduction. The computer hides a code of 4 colours, and you guess it. After each guess, clues tell you how many pegs are the right colour in the right place, and how many are right but misplaced. It plays like the classic Mastermind board game, online.
Below: three modes, how many codes there are, how to crack one in fewer guesses, and how deduction relates to IQ.
How to play
Pick a mode at the top and press Start. Tap a colour to fill the next hole, then Check. The clues say how many pegs are right, never which ones.
Deduction: testing ideas against every clue.
Deduction, with a new code every day.
The same deduction, with digits.
The maths
Colours to the power of pegs: 6 × 6 × 6 × 6 = 1,296. Without repeats, 6 × 5 × 4 × 3 = 360.
| Level | Possible codes |
|---|---|
| Easy: 4 pegs, 6 colours, no repeats | 360 |
| Classic: 4 pegs, 6 colours | 1,296 |
| Hard: 5 pegs, 8 colours | 32,768 |
The bars use a log scale, because every extra peg multiplies the number of codes.
Strategy
Good players do four things:
How the clues work
A dot (●) is a right colour in the right place; a ring (○) is a right colour in the wrong place. Each peg of the code counts only once. Colours are written as numbers here.
So each peg earns a dot or a ring, never both, and the clues never say which pegs they mean.
Mastermind
Here is how to play Mastermind: one player hides a row of 4 coloured pegs, and the other tries to find it in a set number of guesses. A black peg means right colour, right place; a white peg, right colour, wrong place.
Mordecai Meirowitz, an Israeli postmaster, invented Mastermind in 1970, and Invicta Plastics in England launched it in 1971 and 1972. Mastermind is a trademark of its owner; Code Breaker is our own game.
Code Breaker plays the same game against the computer: 4 pegs and 6 colours on the classic board, with a shape on every colour so anyone can play.
Code Breaker doubles as a Mastermind solver: after each game it shows how Donald Knuth’s strategy would have cracked your code. In 1976 he showed it never needs more than 5 guesses.
Skills
Turning clues into facts: if this row has no dots and no rings, none of its colours is in the code.
Keeping every earlier clue in mind while you build the next guess.
Choosing a guess that tells you the most, whatever the answer turns out to be.
And IQ
Not on its own, but it uses two skills IQ tests measure. Each guess is a small experiment, so the game rewards deduction, part of fluid reasoning. Keeping every clue in mind at once leans on working memory.
Practice makes you better at the game; there is little evidence it raises IQ (Simons and colleagues, 2016). For a wider check of your reasoning, try the logical reasoning test or take the online IQ test.
The five areas of a modern IQ test
The five primary index areas of the WISC-V (children, 2014) and the WAIS-5 (adults, 2024). See WAIS-5 index scores explained.
FAQ
Each peg in the code can be matched only once. For each colour, the smaller of its count in your guess and in the code counts; dots (right place) are counted first, and rings make up the rest.
Yes, with 4 pegs and 6 colours. Donald Knuth showed in 1976 that a careful strategy cracks every one of the 1,296 codes in 5 guesses or fewer. After each game we show how his strategy would have cracked your code.
Two pairs, such as 1-1-2-2 (two pegs of one colour and two of another), is the first guess of Knuth’s strategy. Many players prefer four different colours, to learn which colours are in the code.
About 4.34 guesses, found by Kenji Koyama and Tony Lai in 1993 with a full computer search. That strategy needs 6 guesses for a few codes.
It is the same idea. Bulls and Cows is an older pencil-and-paper game with digits: a bull is a right digit in the right place, a cow a right digit in the wrong place. Our Numbers mode plays the same way.
Both give clues about which parts of a guess are right. Wordle’s clues sit on each letter; Code Breaker’s clues only say how many pegs are right, which makes it a purer test of deduction.
Yes. Every colour has its own shape, you can show numbers on the pegs, and the Numbers mode uses digits only. The clue markers differ by shape (a dot or a ring), not by colour.
At midnight where you are. Everyone gets the same code for the same date; your first game of a day counts, and the last 30 days stay playable.
It is good practice in deduction: testing an idea against every clue at once. There is no good evidence that it raises IQ. A full IQ test measures reasoning across many kinds of questions.
It is the same idea: a hidden code of coloured pegs, and clues for right colour, right place and right colour, wrong place. Mastermind is a trademark of its owner; Code Breaker is our own version.
Most boards have rows for 12 guesses; some sets have 10, 8 or 6. Here each level shows how many guesses you have.
Yes. After you crack a code, send the link: your friend gets the same code and sees both scores.
Yes. It is free to play, with no signup, and your scores stay in your browser.
Sources
The full picture
Each game looks at one skill. The IQ test brings speed, reasoning and memory together in one score, with your percentile and a certificate.