J10M

Joue 10 minutes.

Secret Code

Crack the four-color code in ten guesses, guided by the clues.

Ages 10 and up

Secret Code is a deduction game you play against the computer. It hides a combination of four colored pegs, and you have ten guesses to find it. After each guess, it answers with two clues: how many pegs are the right color in the right spot, and how many are the right color but in the wrong spot. Your job is to cross-check those answers until the code has no secrets left.

Everything happens in your browser, with no download, no sign-up and nothing to install. A game takes a few minutes. You don't need reflexes or luck: you need a method, and the fun comes from the moment the clues finally click together. If you grew up playing the classic color code breaker board game, you will feel right at home.

How to play Secret Code

To build a guess, tap the colors in the palette: each color you tap adds a peg to your combination, up to four. On a keyboard, the keys 1 to 6 pick the colors, Backspace erases the last peg you placed, and Enter submits the guess.

Once a guess is submitted, its two clues appear and you build the next one. Your earlier guesses stay on screen, with their clues.

You win as soon as all four pegs are in the right spot. If the tenth guess misses, the game is lost and the code is revealed.

Reading the clues

Every guess gets two numbers.

  • Right spot, shown as solid marks: pegs of the right color, in the right place.
  • Wrong spot, shown as hollow marks: pegs of a color that is in the code, but in a different place.

The clues never tell you which pegs they are about. One solid mark tells you that one of your four pegs is right, not which one. The whole art of the game is figuring that out.

Let us take an example. The code is red, blue, blue, green. You guess blue, red, yellow, green. The green, in fourth place, is in the right spot. The blue and the red are in the code, but elsewhere: they are in the wrong spot. The yellow isn't in the code at all. Answer: 1 right spot, 2 wrong spot.

Each peg of the code only counts once. If the code has only one red and your guess has two, only one red can be counted. And a peg already counted as right spot can't also count as wrong spot: against the code red, blue, blue, green, a guess of four reds gives 1 right spot and 0 wrong spot.

Six colors, six symbols

The code's pegs are chosen among six colors, and the same color can appear more than once. So every position has six possibilities, which makes 6 × 6 × 6 × 6 = 1,296 possible codes. Hitting the right one on your first guess, by chance, is a one in 1,296 shot.

Each color also carries its own symbol. That way you can play by looking only at the shapes, if you mix up some colors or if your screen displays them poorly.

How your score is calculated

The score rewards using few guesses first, then speed:

  • finding the code on your first guess earns 10,000 points;
  • every extra guess takes off 1,000 points;
  • one point per tenth of a second that goes by is taken off too.

Found on the fifth guess in two minutes, the code is worth 10,000 − 4,000 − 1,200 = 4,800 points. On the fourth guess in ninety seconds, it is worth 10,000 − 3,000 − 900 = 6,100.

So one more guess costs as much as a hundred seconds of thinking. It is better to take a minute to choose a good guess than to waste one at random.

Each guess counts for at least one second. The timer starts when the board appears and pauses if you switch tabs. A lost game doesn't go on the leaderboard.

Every score is checked by the server: it rebuilds the code from the same random draw, replays your guesses, and works out the clues and the score on its own.

The leaderboard

Every game draws a new code.

The leaderboard keeps each player's best score. With equal scores, whoever got there first ranks ahead.

Eight tips to crack the code

Open with two colors in pairs. A first guess like 1-1-2-2 tells you about two colors at once, and already a little about their positions.

Add the two clues together. Right spot and wrong spot together tell you how many of your pegs find their color in the code, with each peg of the code used only once. Work out what the code is made of first; the order will come later.

Make the most of a zero. A guess with 0 right spot and 0 wrong spot is excellent news: none of its colors are in the code. You rule them all out in one go.

Reason by elimination. Compare two guesses that differ by just one peg: if the clues change, that change is the reason. Step by step, every position loses candidates.

Stay consistent with the clues. Before you submit, ask yourself: if this guess were the code, would my earlier guesses have received the clues shown? If not, it can't win.

Think about repeats. If you stop finding new colors while pegs are still missing, a color you already found appears more than once. Test it twice.

Take stock after every guess. Sum up in one sentence what the last guess taught you: "one blue, but not in first place." Put end to end, those conclusions point to the code.

Don't forget the clock. Thinking pays off, but there is no point checking a sure guess ten times. When the code is no longer in doubt, submit right away.

From bulls and cows to colored pegs

Long before colored pegs, people played Bulls and Cows with pencil and paper. That game uses digits: the bulls are the digits in the right place, the cows the ones that are present but in the wrong place. In the 1960s and 1970s it moved onto computers, notably under the name MOO.

Around 1970, Mordecai Meirowitz came up with a version using colored pegs, sold from 1971 by the English company Invicta Plastics.

In 1977, the computer scientist Donald Knuth proved that with four positions and six colors, the exact size of Secret Code, five guesses are always enough to find any code with a perfect strategy. Here you get ten guesses: plenty of room to search at your own pace.

For more games of pure deduction, browse the board games category, or try Queen Regions.

Frequently asked questions

Is the game really free?

Yes, completely, with no download and no sign-up.

Do I need an account to be on the leaderboard?

No. A nickname is enough, and you are asked for one the first time you submit a score. Your player ID is then stored in your browser, so clearing the site's data or switching devices starts you from scratch, unless you create a recovery key on your profile page and enter it there with your nickname.

Can a color appear more than once in the code?

Yes. The same color can take two, three or even all four positions. That is what brings the number of possible codes to 1,296.

What do the solid and hollow marks mean?

A solid mark means a peg in the right spot; a hollow mark, a peg of the right color in the wrong spot. They don't tell you which pegs they refer to.

What happens if I don't find the code in ten guesses?

The game is lost and the code is revealed. It doesn't go on the leaderboard.

Can I play if I can't tell colors apart?

Yes. Each color has its own symbol: recognizing the shapes is enough.

Can I play with a keyboard or on a phone?

Both. On a keyboard, the keys 1 to 6 pick the colors, Backspace erases and Enter submits. On a phone, just tap the palette.

More board games

Board games
  • Fleet Duel
    Sink the computer's five ships before it sinks yours.
  • Disc Turnover
    Outflank and flip the computer's discs to own most of the board.
  • International Checkers
    Checkers on the big 10×10 board, against the computer or a friend.
  • Chess
    Chess against the computer at four strengths, or with a friend: castling, en passant, promotion.
  • Tock
    The Quebec marble and card game, played in teams of two: bring your marbles out, send rivals back to start and set your own house rules.
  • Five Dice
    Five dice, three rolls, thirteen boxes to fill: go for five of a kind and the bonus.