Code Breaker Strategy: Crack the Secret Colour Code in Five Guesses

Code Breaker looks like a guessing game, but it is really a logic puzzle. Every guess gives you clues, and a good code breaking game strategy turns those clues into the answer in just a few tries. This guide shows you how to read the pins, which first guess to make and, step by step, how a real code is cracked in four guesses.
Open our free Code Breaker game in another tab and follow along.
How Code Breaker works
The computer hides a secret code of four coloured pegs, chosen from six colours. You place a guess of four colours and press Check. The game answers with small clue pins, and you use them to plan your next guess. You have ten rows to find the code, and fewer guesses and less time give a higher score. The idea comes from a classic peg-board deduction game invented in 1970.
Reading the clue pins
Everything depends on understanding the two kinds of pins:
- Pink pin: a colour in exactly the right place.
- White pin: a right colour in the wrong place.
- No pin: that colour is not in the code, or you used it more times than the code does.
The most important detail is that the pins are not lined up with your pegs. They tell you how many colours are right, never which ones. Working that out is the puzzle.
How many codes are possible?
| Mode | Code | Possible codes |
|---|---|---|
| Easy | 4 pegs, 6 colours, no repeats | 360 |
| Classic | 4 pegs, 6 colours, repeats allowed | 1,296 |
| Expert | 5 pegs, 8 colours, repeats allowed | 32,768 |
That sounds like a lot, but each guess cuts the list down dramatically. A good guess in Classic mode can remove more than nine out of every ten possible codes in one go.
The best first guess
In Classic mode, open with two colours used twice, such as pink, pink, cyan, cyan. It tests two colours at once and also gives you position information. This is the same opening the computer scientist Donald Knuth used in 1977, when he proved that any four-peg, six-colour code can be cracked in five guesses or fewer.
In Easy mode, where colours never repeat, use four different colours instead. If you get four pins in total, you already know which colours are in the code and only need to find their order.
A solved example, step by step
Here is a real game in Classic mode. The secret code was green, cyan, pink, yellow, and the bar shows how many codes were still possible after each guess.
- Pink, pink, cyan, cyan: two white pins. Two of these pegs are right colours in the wrong places, so pink is not in slots 1 or 2, and cyan is not in slots 3 or 4. Only 96 codes remain.
- Cyan, yellow, pink, green: one pink and three white pins. All four colours are in the code, but only one is in the right place. Just 2 codes are left.
- Cyan, green, yellow, pink: four white pins. Right colours, all in wrong places, which leaves exactly one possible code.
- Green, cyan, pink, yellow: four pink pins. Code cracked in four guesses.
7 rules for cracking any code
- Count total pins first. Pink plus white tells you how many of your colours are in the code. Positions come later.
- A row with no pins is gold. It rules out every colour in it at once.
- Stay consistent. Every new guess should agree with all earlier clues, or it cannot be the answer.
- Change one or two pegs at a time when you are close, so you know exactly what caused a change in the pins.
- Use position clues. If a colour gave a white pin in slot 1, it is somewhere else in the code, never in slot 1.
- Remember repeats. In Classic and Expert, a colour can appear twice. Do not assume four different colours.
- Write it down in your head. Say the facts you know: "pink is in, not first; cyan is in, not last." It keeps your deductions clear.
Frequently asked questions
What is the best first guess in Code Breaker?
In Classic mode, a guess with two colours used twice, such as pink pink cyan cyan, is a strong opening. It tests two colours at once and was the opening used in Donald Knuth’s famous five-guess strategy.
Can every code be cracked in five guesses?
Yes, in the four-peg, six-colour version. In 1977 Donald Knuth showed that a careful strategy can always find the code in five guesses or fewer.
What do the pink and white pins mean?
A pink pin means one of your colours is in exactly the right place. A white pin means one of your colours is in the code but in a different place. The pins do not tell you which pegs they refer to.
Can colours repeat in the secret code?
In Classic and Expert, yes. In Easy mode every colour in the code is different, which makes the puzzle simpler.
Is Code Breaker the same as Mastermind?
Code Breaker follows the same deduction idea as the classic peg-board game invented in 1970, with four pegs and six colours in the standard mode.
Play Code Breaker
Ready to test your logic? Open our free Code Breaker game and try the two-colour opening in Classic mode. If you enjoy deduction, try Word Guess with our list of the best starting words, explore more brain games for adults, or browse all our puzzle games.