Code Breaker looks like guesswork at first: four coloured pegs, six colours, and 1,296 possible codes. It isn’t. Every row of black and white key pegs rules out hundreds of codes, and a breaker who reads them carefully finds the answer in a handful of guesses. This tutorial teaches a simple method you can follow in your head, plays a whole game with it, and adds tips for the bigger board and for Bulls and Cows. If you are new to the game, read the Code Breaker rules first.
What you will learn
- Why two pairs make a strong first guess.
- How to count the colours in the code in three guesses.
- How to turn black and white pegs into “here” and “not here” notes.
- How to build a guess that fits every clue.
- How the same ideas work with digits in Bulls and Cows.
Your first game, step by step
Start a game against the computer with the defaults: 4 colours of 6, repeats on, 10 guesses. In this example the hidden code is green, purple, blue, purple. Of course you don’t know that yet.
Guess 1: red, red, blue, blue. The answer is one black, no white. So exactly one peg in the code is red or blue, and it is already in the right place: a red in place 1 or 2, or a blue in place 3 or 4. Three of the four pegs are green, yellow, purple or orange.
Guess 2: green, green, yellow, yellow. One black, no white again. Exactly one green or yellow, also in its right place: a green in place 1 or 2, or a yellow in place 3 or 4.
Guess 3: purple, purple, orange, orange. One black, one white. That is two more pegs from purple and orange. Now add up: one from red and blue, one from green and yellow, two from purple and orange. That makes four, so every colour of the code is accounted for, and 24 codes are still possible.
This opening, three pairs of pairs, is the heart of the method. In three guesses you know how many pegs come from each pair of colours, and you already have hints about places.
Guess 4: build a code that fits every clue. Try green in place 1 (that fits guess 2), purple in place 2 (the black from guess 3), another purple in place 3 (the white from guess 3: a purple, but not where guess 3 had one), and blue in place 4 (the black from guess 1). Guess green, purple, purple, blue. The answer is two black, two white. Every colour is right; two are in the right place.
Only two codes still fit all four rows: purple, green, purple, blue, and green, purple, blue, purple. You can’t tell them apart without guessing one.
Guess 5: green, purple, blue, purple. Four black. Cracked in five. Had the code been the other one, guess 6 would have cracked it, still well inside the ten allowed.
Strategy tips
1. Open with two pairs
A first guess with two colours in pairs (red, red, blue, blue) splits the 1,296 codes into smaller groups than four different colours do. Its worst answer leaves 256 codes; four different colours can leave 312, and one colour in every place up to 625. If Repeated colours is off, there are no pairs in the code, so open with four different colours instead.
2. Find the colours, then the places
Black plus white is the number of pegs in the code from the colours you guessed. Pairs make that count easy to use: after red-red-blue-blue, green-green-yellow-yellow and purple-purple-orange-orange, the three totals add up to the whole code. (If they add up to less than four, one colour fills three or four places, more than a pair can count.) Once you know the colours, the game becomes a smaller puzzle about places.
You can often skip the third guess: four pegs minus the first two totals is the number of purple and orange pegs, as long as no colour fills three places.
3. Love a zero
No key pegs at all is the most useful answer early on: every colour in that guess is out of the code. Use the dropped colours afterwards as filler. A guess like red, orange, orange, orange, when orange is known to be out, tests red in place 1 and nothing else.
4. Keep “here” and “not here” notes
Every peg that scores no black is not in that place. Every black means one of the guess’s pegs is right where it is. Write the notes on paper, or say them out loud: “green is not first or second”. Three or four of these notes usually pin down a whole code.
5. Every guess should fit every clue
Before you tap Check, test your guess against each earlier row. Pretend it is the code and score the old guesses against it. If any row would get different key pegs, your guess can’t be the answer, so change it. A guess that fits everything might win outright, and if it doesn’t, it still cuts the remaining codes down.
Try it on two boards: tap the code that could still be the secret, and each row shows whether that code fits it.
Which code fits?
Puzzle 1 of 2 · Fit every clue
You are breaking the code, with the three pairs from the tutorial’s game on the board. Which code below could still be the secret?
Tap a code to check it against the three rows.
6. Change one or two things at a time
When you are close (three black, say), move or swap only one or two pegs per guess. Then a change in the key pegs points straight at the peg you moved.
7. Watch the guess count
You have 10 guesses, or 12 if you chose it. If you reach guess 7 with several codes still possible, choose a guess that separates them rather than one that only might win.
How computers do it
In the 1970s the computer scientist Donald Knuth showed that every code of 4 pegs from 6 colours can be cracked in five guesses or fewer. The idea is simple to say and hard to do by hand: for every possible guess, work out the worst answer it could get and how many codes that answer would leave, then choose the guess whose worst case is smallest. His first guess was two pairs, the same as in tip 1. You can’t search 1,296 codes in your head, but you can borrow the spirit: prefer guesses whose every answer teaches you something.
The bigger board: 5 colours of 8
With five places and eight colours there are 32,768 codes, so the same method takes longer.
- Open with pairs and a single: red, red, blue, blue, green, then yellow, yellow, purple, purple, orange. Pink and teal are what is left over.
- Keep notes from the start; the place clues pile up quickly.
- Choose 12 guesses under More options while you learn.
Bulls and Cows tips
Choose 4 digits to play with numbers. The code is four different digits, and so is every guess.
- Open with 1234, then 5678. Bulls plus cows from the two guesses tells you how many of the code’s digits are among 1 to 4 and 5 to 8; the rest come from 9 and 0.
- An example. For the code 4271, the guess 1234 gets one bull (the 2) and two cows (the 1 and the 4), and 5678 gets one bull (the 7). So three digits come from 1 to 4, one from 5 to 8, and 9 and 0 are out. A guess like 4217 then scores two bulls and two cows: all four digits found, and two of them placed.
- Swap in pairs. When every digit is known, swapping two digits and watching the bulls change shows which places were right.
Setting a hard code
When it is your turn to set the code for a friend:
- With repeats on, use them. A breaker who only ever guesses four different colours can be caught out by a code like blue, blue, yellow, blue.
- Avoid simple patterns, such as one colour in every place or the colours in their palette order.
- Tap Random if you can’t decide: every code it picks is as likely as any other.
Common beginner mistakes
- Reading a key peg as a place. The pegs are always shown blacks first; they never point at a hole.
- Counting extra copies. Four reds against a code with one red earns one key peg, not four.
- Forgetting old clues. A new guess has to agree with every earlier row, not just the last one.
- Changing everything at once. When you are close, small changes tell you more.
A practice plan
- Play a few rounds with Repeated colours off, where every place is a different colour.
- Switch repeats on and use the three-pair opening every time.
- Count your guesses per round and try to beat your best.
- Try 4 digits for a change, then the big board with 12 guesses.
When you are ready, play Code Breaker against the computer, or hand the phone to a friend and set them a code. For another quick puzzle on one screen, try Hangman.


