Logic Puzzle

Code Breaker

Crack the secret color code using logic and deduction

0:00
Code
?
?
?
?

4 positions · 6 colors · 12 attempts

No duplicates

What is Code Breaker?

Code Breaker is a classic logic and deduction puzzle game based on the timeless code-breaking concept. The computer generates a secret code made up of colored pegs, and your mission is to crack it using nothing but logic, pattern recognition, and the feedback you receive after each guess.

Originally popularized as a board game in the 1970s, this digital version brings the experience to your browser with modern enhancements: four difficulty levels from Easy to Expert, a hint system for when you get stuck, comprehensive statistics tracking, and a scoring system that rewards both speed and efficiency. Play for free — no downloads, no signup, no ads blocking your gameplay.

How to Play Code Breaker

1
Choose Difficulty

Select from Easy (4 pegs, 6 colors) up to Expert (6 pegs, 8 colors). Higher difficulties allow duplicate colors in the secret code.

2
Build Your Guess

Click a position in the current row, then select a color from the palette below. Fill all positions to complete your guess.

3
Read Feedback

After submitting, check the feedback pegs. Filled = right color, right spot. Hollow = right color, wrong spot. Empty = not in code.

4
Crack the Code

Use deduction to narrow down possibilities. Crack the code before running out of attempts to win and earn points!

Understanding Feedback Pegs

Black (Filled) Peg

One of your colors is correct AND in the correct position. This is an exact match — keep this color where it is.

White (Hollow) Peg

One of your colors exists in the secret code but is in the wrong position. Try moving this color to a different spot.

Empty (No Peg)

This color is not in the secret code at all. Eliminate it from future guesses to narrow your options.

Note: Feedback pegs are shown in no particular order. They do not correspond to specific positions in your guess — only the total counts matter.

Strategies & Tips

Beginner Strategy

  • Start with all different colors in your first guess to identify which colors are present in the code.
  • Keep colors that earned black pegs in their exact positions for the next guess.
  • If you get zero feedback for a guess, none of those colors are in the code — eliminate them all.
  • Focus on finding the correct colors first, then worry about positioning.

Advanced Strategy

  • Use your first two guesses to test all available colors (e.g., colors 1-4, then 5-6 plus two known).
  • When you get white pegs, systematically try those colors in each remaining position.
  • Count the total feedback pegs — if you have N colors identified and get N total pegs, you have found all the colors.
  • On Easy mode (no duplicates), once you place a color correctly, it cannot appear elsewhere.

Pro Strategy

  • Each guess should maximize information. Avoid repeating a guess pattern that tells you nothing new.
  • Track which colors are "impossible" for each position based on accumulated feedback.
  • On difficulty levels with duplicates, a color getting a white peg does not eliminate it from other positions.
  • Optimal play on 4-peg 6-color games averages about 4.6 guesses — aim for under 5.
  • Save hints for the endgame when you have narrowed down to 2-3 possibilities and need a tiebreaker.

Keyboard Shortcuts

Select and place color1-8
Move between positionsLeft / Right
Submit guessEnter
Use hintH
Undo last placementBackspace
New gameN
Cycle difficultyD
Toggle soundM

Frequently Asked Questions

Code Breaker is a logic puzzle where the computer generates a secret code of colored pegs. Click a position in the current guess row, then click a color from the palette to fill it. After filling all positions, submit your guess to receive feedback. Black pegs mean correct color in the correct position. White pegs mean correct color but wrong position. Use this feedback to deduce the secret code before running out of attempts.
After each guess, feedback pegs appear to the right of your guess row. A filled (black) peg means one of your colors is exactly correct — right color, right position. A hollow (white) peg means one of your colors exists in the code but is in the wrong position. No peg means that color is not in the code. Important: the feedback pegs are not in any particular order — they do not correspond to specific positions in your guess.
Start with a guess using all different colors to identify which colors are in the code. On subsequent guesses, keep colors that got black pegs in their positions and try swapping colors that got white pegs. Eliminate colors that produced no feedback. For advanced play, use each guess to maximize information gained. A classic opening on 4-position games is to use the first two guesses to test all available colors.
The number of possible codes depends on the difficulty level. Easy (4 positions, 6 colors, no duplicates): 360 combinations. Medium (4 positions, 6 colors, with duplicates): 1,296 combinations. Hard (5 positions, 8 colors, with duplicates): 32,768 combinations. Expert (6 positions, 8 colors, with duplicates): 262,144 combinations.
Code Breaker is based on the same classic code-breaking logic puzzle. The core mechanics are identical: a secret code of colored pegs, guessing with feedback, and deduction. Code Breaker adds modern enhancements including four difficulty levels, a hint system, detailed statistics tracking, keyboard controls, and a responsive design that works on any device.
It depends on the difficulty. In Easy mode, every color in the code is unique — no duplicates allowed. In Medium, Hard, and Expert modes, the code can have duplicate colors. This makes the puzzle significantly harder because getting a white peg for a color does not mean only one instance exists in the code.
You start with 1,000 base points. Each guess used deducts 100 points. Each hint used deducts 200 points. You earn +50 bonus points for each unused attempt remaining, and +200 if you solve the code in under 60 seconds. If you fail to crack the code, your score is 0. The scoring rewards both speed and efficiency.
Press 1-8 to select a color and place it in the active position. Arrow Left/Right to move between positions. Enter to submit your guess. H to use a hint. Backspace to undo the last placed color. N to start a new game. D to cycle through difficulty levels. All shortcuts work on desktop browsers.
You get up to 2 hints per game. Each hint reveals one correct color in its correct position by filling it in for you. Hints cost 200 points each from your final score. Use them strategically when you are stuck — but try to solve the code without hints for the best score.
Yes! Code Breaker is completely free to play. No ads blocking gameplay, no signup required, no downloads needed. Your statistics and progress are automatically saved in your browser's local storage so you can track your improvement over time.
Yes! Code Breaker is fully responsive and works on smartphones, tablets, and desktop computers. The interface adapts to any screen size with touch-friendly controls. Simply open your browser and start playing.
The hint system reveals one correct color in its exact position. You can use up to 2 hints per game. Each hint deducts 200 points from your final score. Hints are placed directly into your current guess row, so you can build the rest of your guess around the revealed information.

More Games

Need a tool? Ask us!
Code Breaker - Free Mastermind Puzzle Game Online | YaliKit