Code Breaker

A hidden row of coloured pegs is waiting to be guessed. Each try tells you how many you have put exactly right and how many are the right colour in the wrong place, and you have ten tries to crack it.

How to play

The scoring never says which peg it is talking about, only how many, so what you learn comes from the difference between one guess and the next rather than from any single row.

  1. Build a guess Tap colours from the row underneath to fill the slots.
  2. Press Check The feedback pegs appear beside your guess.
  3. Read the feedback A dark peg means one is exactly right. A pale peg means a colour is right but in the wrong place.
Full instructions
In depth

Cracking the hidden colour code with logic

How the feedback pegs work, what the three difficulty levels change, the opening guess that teaches you the most, and the reasoning that turns ten guesses into more than enough.

Screenshot: How to play Code Breaker
How to play Code Breaker as it appears when the page opens.

What you are solving

A sequence of coloured pegs is hidden behind a shield at the top of the board. You do not know which colours they are or where they sit. Your job is to work it out by making guesses and reading the feedback.

Each guess is a complete row of colours. After you submit it, a set of small feedback pegs appears beside it. Those pegs tell you how close you were, but they do not tell you which positions were right. That gap between what you know and what you need is the entire game.

The two kinds of feedback peg

A dark peg means one of your colours is exactly right, in the correct position. A pale peg means a colour appears in the hidden code but you put it in the wrong spot. No peg at all means that colour is not in the code, or every copy of it has already been accounted for.

The pegs are sorted. Their order has nothing to do with which slot they refer to. You might see two dark pegs and one pale peg, but you cannot tell from their position which of your four slots scored the dark pegs. That deliberate ambiguity is what makes the puzzle a deduction rather than a guess.

How duplicates are counted

If the hidden code has one red peg and you guess two reds, only one gets credit. The scoring works in two passes. First it checks exact matches and removes those from both sides. Then it looks at the remaining pegs and counts partial matches from what is left over. This prevents the feedback from awarding more matches than the code actually contains.

That two-pass count is what makes reasoning sound. If two reds in your guess produce only one pale peg, you know the code has exactly one red. A simpler count that checked each slot on its own could report two partial matches and mislead you into thinking the code had two.

The three difficulty levels

Easy uses four colours and a code that is four pegs long. No colour repeats, so every position holds a different hue. You have ten guesses. With only four colours and no repeats, there are just twenty-four possible codes. This is the level for learning how the feedback works.

Normal raises the palette to six colours and keeps the code at four pegs. Repeats are allowed, which expands the code space to 1,296 possibilities. You still have ten guesses, and with careful play five or six are usually enough.

Hard uses seven colours and stretches the code to five pegs. Repeats are still allowed, and you get twelve guesses. The longer code and wider palette make elimination slower, so the extra two guesses earn their keep.

Controls on the board

Below the board sits a row of coloured chips, one for each available colour. Tap a chip to place that colour in the next open slot of your current guess. The Undo button removes the last colour you placed, so you can correct a slip without starting the row over.

Once every slot in the row is filled, the Check button becomes active. Press it to submit the guess. The feedback pegs appear beside your row, the row locks in place, and the next blank row becomes the current one. You cannot go back and change a guess that has already been submitted.

Spend the first guess on information

A common beginner mistake is to aim the first guess at winning immediately. The odds of guessing a six-colour, four-peg code on the first try are less than one in a thousand. A guess chosen at random teaches you almost nothing when it misses.

Instead, use the first guess to learn which colours appear in the code. Place four different colours. The total number of dark and pale pegs tells you how many of those four are present. If you get two pegs, you know two of your four colours are in the code and two are not. That single number eliminates a large chunk of the search space before your second guess.

On Hard, with five slots and seven colours, you cannot test all seven in one row. Use the first two guesses to sweep through them. After two guesses you will know exactly which colours are in play.

Change one thing at a time

After your first guess, resist the urge to rebuild the whole row. Take the guess that gave you the most information and change a single peg. If the number of dark pegs goes up by one, the new colour in the new position is right. If it goes down, you moved something that was correct.

This one-change method is slow but airtight. Every guess tells you something specific about a single position. After three or four rounds of it, you will often know enough to fill in the rest by logic alone.

Tracking what you know

Every submitted guess stays visible on the board, with its feedback pegs beside it. Scroll up and look at them together. The guesses form a set of constraints, and the hidden code is the one sequence that satisfies all of them at once.

Pay attention to zeros. A guess that returns no pegs at all is extremely useful. It tells you that none of those colours appear in the code. On Normal, that wipes out four colours in one guess and leaves only two possibilities for every slot.

Keep track of which colours you have confirmed and which you have ruled out. The more colours you eliminate, the fewer candidates remain for each position, and the faster the answer narrows down.

When repeats change the logic

On Easy, every colour appears at most once. That makes elimination straightforward. Once you know a red is in the code, it occupies exactly one slot. Once you place it, red is done.

On Normal and Hard, a colour can appear more than once. One dark peg for red does not mean there is only one red. There could be two or three. You need to test for duplicates by guessing rows with repeated colours and reading the peg count carefully.

If you guess two reds and get one more peg than you expected, the code likely has a second red. If the count does not rise, one red is all there is. This duplicate testing adds a layer that Easy does not have, and it is where most Normal players lose time.

Mistakes that cost guesses

  • Guessing randomly instead of building on what you know. Every guess should be shaped by the feedback so far.
  • Changing too many pegs at once. You get a new peg count, but you cannot tell which change caused it.
  • Forgetting that pegs are sorted. The leftmost dark peg does not refer to your leftmost slot.
  • Ignoring zero-peg results. They are the most powerful eliminator in the game.
  • On Normal and Hard, assuming no repeats. If you cannot place a confirmed colour in any open slot, it may appear in a slot you thought was a different colour.

A short example on Easy

Four colours are available, the code is four pegs long, and no colour repeats. Guess all four colours in order. Suppose the feedback is two dark pegs and two pale pegs. Every colour is in the code, so the job is to find the right positions.

Swap the first two colours and submit again. If the dark count goes up, one of those two is now in the right place and was wrong before. If it drops, one was already correct and you have just moved it out. Either way, you have learned which of those two slots holds which colour. Repeat the same trick with the other pair, and the code falls in three or four guesses total.

Nothing leaves your browser

The hidden code is picked by your own browser from a random number generator. No server knows the answer, no guess is uploaded, and no account is involved. Your best score is stored in this browser on this device and will not appear on any other machine. Once the page has loaded, the game works offline.

Help

How to play Code Breaker

The scoring never says which peg it is talking about, only how many, so what you learn comes from the difference between one guess and the next rather than from any single row. Changing a single peg at a time is safe but slow, and with ten tries a guess that rules out several colours at once is usually worth more.

Build a guess

Tap colours from the row underneath to fill the slots.

Press Check

The feedback pegs appear beside your guess.

Read the feedback

A dark peg means one is exactly right. A pale peg means a colour is right but in the wrong place.

Work it out

The pegs are sorted, so their order tells you nothing about which position was correct.

Crack it in ten

Twelve on the hard level.

Runs on your device

The whole game is played inside this page. Nothing is uploaded, there is no account, and your best score is stored in this browser only. Once the page has loaded it works offline.

Good to know

Spend the first guess on information

Something like four different colours tells you how many of them appear at all. A guess aimed at winning immediately usually teaches you nothing.

Change one thing at a time

Once you have some feedback, altering a single peg and comparing the result tells you exactly what that peg was worth.

Duplicates are counted properly

If the code has one red and you guess two, only one is credited. That is what makes the deduction sound.

Six colours, four slots is 1296 codes

It can always be solved in five guesses with perfect play. Ten is a comfortable margin.

Common questions

What do the small pegs mean?
A dark peg for each colour that is exactly right, and a pale one for each colour that is in the code but in a different position.
Do the pegs tell me which position?
No, deliberately. They are sorted, so you know how many but not where.
Can a colour appear twice in the code?
On Normal and Hard, yes. On Easy every colour is different.
Is it free?
Yes — no account, no limit on how many games you play, and no ads inside the game area itself. Ads on the page around it pay for the site.
Does it work on a phone?
Yes. The board scales to your screen and the controls are made big enough to use with a thumb.
Where is my best score kept?
In your browser on this device. It is never sent anywhere and will not follow you to another computer.