Deductive Code Cracking

Codebreaker

An elegant deductive color puzzle. Crack the secret 4-color code within 10 attempts. Click peg slots to place colors, or tap the palette to quick-fill!

Colors: 6
Repetitive Colors
Attempt1 / 10
StatusDECODING
Moves0
Time0:00
1
2
3
4
5
6
7
8
9
10
Select Color:

💡 Auto-Fill: Tap a color to place it in the next empty slot of Row 1.

Deductive Cryptanalysis Manual

How to Master Codebreaker Puzzles

The Official Codebreaker & Mastermind Rules

Codebreaker is a modern web-based adaptation of the classic paper-and-pencil game Bulls and Cows, popularized as the board game Mastermind in the 1970s.

The game begins with the computer generating a secret sequence of 4 colored pegs chosen from 6 available colors. By default, duplicate (repetitive) colors are allowed in the secret sequence (making it more challenging). However, you can toggle Repetitive Colors off to ensure all 4 hidden pegs are completely unique, which is a great option for a more strategic and relaxed 10-attempt solving experience!

Your objective is to guess the secret code in 10 rows or fewer. Every guess is evaluated and receives feedback:

  • Green Glow Pegs: The number of pegs that are correct in both color and grid position.
  • Light Silver Pegs: The number of pegs that are correct in color, but placed in the wrong position.
  • The feedback pegs are displayed in a 2x2 grid in no particular order, so you must use deduction to align colors with positions!
The Legendary 5-Guess Winning Strategy (Knuth Minimax Algorithm)

In 1977, the legendary computer scientist Donald Knuth published a mathematical paper proving that Codebreaker (with 4 slots and 6 colors) can be solved in 5 guesses or fewer!

To implement his elite minimax strategy, follow these rules of thumb:

  • The Optimal Opening Guess (AABB): Always start with a double-duplicate pattern, specifically two pegs of one color and two pegs of another (e.g., [Red, Red, Blue, Blue]). Knuth demonstrated that starting with four different colors (e.g., [Red, Blue, Green, Yellow]) does not guarantee a win within 5 moves.
  • Eliminate the Impossible: For your subsequent moves, only consider color combinations that would yield the exact same feedback if they were the secret code. If you have 1 Green feedback on a guess, any candidate secret code that would yield 0 or 2 Green feedback against your guess is mathematically impossible and can be eliminated!
  • The Minimax Pivot (Worst-Case Reduction): Choose the next guess that minimizes the maximum number of remaining possibilities. Sometimes this means submitting an "impossible" guess to act as a probe—by testing it, you guarantee the elimination of a massive chunk of remaining candidates regardless of the feedback received.
How Duplicate Colors impact Feedback Peg Math

One of the most common points of confusion in Codebreaker is how duplicate colors are scored. To protect deductive integrity, our system uses a strict two-pass matching algorithm:

Imagine the secret code is [Red, Red, Blue, Green] and your guess is [Red, Blue, Blue, Blue]:

  1. First Pass (Exact Matches): The first peg (Red) and third peg (Blue) match perfectly in both color and position. This yields 2 Green (Exact) pegs. These matched pegs are now locked.
  2. Second Pass (Color-Only Matches): The second peg of your guess is Blue. Since the only Blue peg in the secret code was already matched exactly in step 1, this Blue peg does not receive any partial credit. This prevents duplicate colors in your guess from getting "double points"!
  3. Thus, the final feedback for this guess is exactly 2 Green pegs and 0 Silver pegs.

Player guide

Codebreaker Player Guide

Crack the hidden color code by testing guesses and reading feedback carefully.

Game

Mastermind-Inspired Deduction Puzzle

Codebreaker is a deduction puzzle inspired by the classic Mastermind format. Your objective is to discover a secret code of four colored pegs within 10 attempts.

How to play

Guess the Colors and Positions

The computer generates a secret code of four colors, and colors can repeat. Submit guesses to learn which colors are correct and whether they are in the right positions.

A black feedback peg means one color is correct and correctly placed. A white peg means one color exists in the code but belongs elsewhere. Empty feedback means that color is not part of the secret code. The feedback positions do not match the positions in your guess; they only show totals.

Strategy

Change One Idea at a Time

A strong opening is to test colors in pairs, such as two of one color and two of another. That quickly tells you whether those colors exist while testing several positions at once.

Once you know a color belongs in the code, change only a few parts of the next guess so you can isolate what caused the feedback. Compare each row to the previous one and narrow the possible codes until only one arrangement remains.