gekro
GitHub LinkedIn

Code Breaker

Crack a secret code of symbols in a limited number of guesses, with exact hints and a solver that replays a classic strategy on your own code.

Guess 1 / 10

Best -

Wins 0

Secret code

Your guesses

    Current guess

    • Filled square: right symbol, right place
    • Hollow diamond: right symbol, wrong place
    • Faint dot: nothing for that position
    • Number of right symbols in the right place
    • Number of right symbols in the wrong place

    Click a slot, then a symbol, or type its number. Arrow keys move between slots, Backspace or Delete clears one, Enter submits, H gives a hint. Every symbol has a digit, a shape and a colour, so you never need colour to tell them apart. A score is two numbers with a symbol each: a check mark for the right symbol in the right place, a double arrow for the right symbol in the wrong place. A best result only counts if you did not use a hint.

    How the hint and the solver work

    The hint lists every possible code and removes the ones that would have scored differently on your guesses. What is left is exactly the set of codes that could still be the secret, so the count it shows is exact.

    The solver uses the strategy Donald Knuth published in 1977. It scores each possible guess against every code that is still possible, finds the guess whose worst-case score leaves the fewest codes standing, and plays that one, preferring a guess that could itself be the answer. For the 5-peg, 8-symbol game there are too many codes to try every guess, so it samples among the codes still possible.

    As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.

    © 2026 Rohit Burani · MIT · Built at gekro.com · View source ↗

    Guide

    How to play

    The computer picks a secret code: a row of pegs, each one a symbol. You build a guess and submit it, and the game scores it with two numbers:

    • Right place: pegs that are the right symbol in the right position.
    • Right symbol, wrong place: pegs that are a symbol the secret contains, but in a different position.

    A score of 2 / 1 means two pegs are right in place and one more is the right symbol in the wrong place. Next to each guess the score is written as two numbers, each with a symbol: a check mark and a number for the right symbol in the right place, a double arrow and a number for the right symbol in the wrong place. Small markers repeat it: a filled square for each right place, a hollow diamond for each right symbol in the wrong place, a faint dot for a position that scores nothing. Use the scores to narrow the code down before you run out of guesses.

    Before you start you can choose the code length (4 or 5 pegs), the number of symbols (6 or 8), whether a symbol may appear more than once, and how many guesses you get (8, 10 or 12). The default is 4 pegs, 6 symbols, repeats allowed and 10 guesses.

    Click a slot in the current guess, then a symbol, or type the symbol’s number. Arrow keys move between slots, Backspace or Delete clears a slot, Enter submits, and H asks for a hint. With repeats off, the Submit button stays disabled while a symbol is used twice.

    Every symbol has a digit, a shape and a colour: 1 circle, 2 square, 3 triangle, 4 diamond, 5 star, 6 cross, 7 hexagon, 8 pentagon. The symbols are rounded tiles in the site’s sky, rose, amber, green, violet, lime, teal and orange tints. You never need to tell colours apart, because the digit and the shape say the same thing.

    How it works

    Scoring with duplicates. Counting is easy to get wrong when a symbol appears more than once. Each secret peg can match only one guess peg. The scorer takes the exact matches first, then, for each remaining guess peg, uses up one remaining secret peg of the same symbol if there is one. So against a secret with a single 1, a guess of 1 1 1 1 scores one right place and nothing else. The tests write out a dozen of these tricky cases by hand and check that the score is symmetric and that the two numbers always add up to the number of symbols the two codes share.

    The hint is an exact count. The tool builds the full list of possible codes (1296 for the default game, 4096 for 4 pegs and 8 symbols, 7776 for 5 pegs and 6 symbols, 32768 for 5 pegs and 8 symbols). With repeats off the lists are shorter: 360, 1680, 720 and 6720. A hint removes every code that would have scored differently on your guesses and shows what is left. When one code remains it names it; otherwise it gives the count and, if every remaining code agrees on a position, says which symbol goes there. Asking for a hint means the game no longer counts toward your best.

    The solver. After a game ends, Solver plays replays a Knuth-style minimax strategy on your same secret, one guess every 600 milliseconds (instantly if your system asks for reduced motion). It opens with 1 1 2 2. After that, it scores every possible guess against every code still possible, finds the guess whose worst-case outcome leaves the fewest codes, and plays it, preferring a guess that could itself be the answer. The test suite runs it against all 1296 codes of the default game: it cracks every one in at most 5 guesses, and it averages 4.476 guesses (5801 guesses in total; 1 code takes 1 guess, 6 take 2, 62 take 3, 533 take 4 and 694 take 5). In the 4-peg, 6-symbol game with no repeats it also cracks all 360 codes in at most 5 guesses.

    Trying every guess against every remaining code is too slow for the larger games (the biggest has 32768 codes). There the solver caps its work per step at 450,000 scored pairs: it compares only an evenly spaced sample of the codes that are still possible. On the computer I timed it on, the slowest step I saw (25 random secrets in each of the eight setups) took under 100 milliseconds, and a phone will be slower. This is not Knuth’s full guarantee, so the solver’s guess count on the larger games is not pinned the way the default game is.

    Privacy and storage

    Nothing is uploaded and there is no account. Your best guess count for each setup and your total of games won without a hint are saved in your browser’s local storage, as small whole numbers inside a small JSON object, under one key. Clearing site data removes them. The secret is chosen with your browser’s secure random number generator and exists only in the page.

    Limits

    • The at-most-5-guesses result is for the default game and the 4-peg, 6-symbol no-repeat game only. The solver is not proven to be optimal in the other setups.
    • Only games won without a hint count toward your best and your wins. A game restarted with the same secret (the Reset button) after you made a guess, used a hint or finished the game never counts, because by then you have seen scores or the answer. Pressing Reset before you have done anything leaves the game counting. Start a new game for a fresh secret.
    • The game is always played against the computer, one secret at a time. There is no daily code and no two-player mode.
    • Best results are per browser and per setup. Changing browser or clearing site data starts them over.

    Everything runs locally in your browser.

    All Fun tools →

    For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.