An exploration into the fundamental mechanics of code-breaking puzzles
Prototyped with Gemini
Behind games like Mastermind, Wordle,
Minesweeper, and Guess Who? lies a single, elegant
mathematical structure. This demo strips away all visual themes to
expose the raw engine of binary deduction.
Imagine cracking a secret code made entirely of 1s and 0s.
When you guess, the system won't tell you which numbers are
right. It only gives you a score showing how many numbers are in
the correct spot. Your goal is to deduce the secret code in as few tries
as possible.
Example Walkthrough
Let's say the code is 3 digits long, and the secret target is
000.
You guess 100. The system replies: 2/3 matches.
You guess 010. The system replies: 2/3 matches.
You guess 001. The system replies: 2/3 matches.
Notice the pattern: every time you change a '0' to a '1', your score
drops. That proves every single '1' is a mistake. The only logical
answer is that the code is all zeros. You guess 000, receive a
3/3 match, and solve the puzzle!
Interactive Simulator
Grab a pen and paper. Use logic to eliminate possibilities in as few
moves as possible.
Related Concepts & Further Reading
Mastermind:
The iconic 1970s code-breaking board game where players deduce a
secret sequence of colored pegs using positional match feedback.
Knuth's Five-Guess Algorithm (1977):
Donald Knuth's paper proving that any standard Mastermind puzzle can
be solved in 5 moves or fewer using a strategy that always plans for
the worst-case scenario.
Constraint Satisfaction Problems (CSP):
A mathematical framework where state values must fulfill a set of
conditions. In this puzzle, each query acts as a strict new rule the
final answer must follow.
Boolean Satisfiability (SAT):
The fundamental computer science problem of determining whether
there exists an assignment of binary variables that satisfies a
given Boolean formula.
Hamming Distance (1950):
A mathematical way to measure the number of positions at which two
equal-length binary sequences differ. The match score directly
computes this value.
Shannon Entropy & Information Theory (1948):
Claude Shannon's mathematical formulation of information content. In
sequence deduction, each query measurably shrinks the uncertainty of
the secret target.
Combinatorial Group Testing (1943):
First developed by Robert Dorfman during WWII to screen large
populations efficiently, group testing tests groups of items at once
to find the correct answer faster.
Guess Who?:
The iconic visual elimination game where players use binary trait
questions (e.g., "Does the character wear a hat?") to narrow down a
secret suspect from a pool.
Wordle:
Modern web-based word puzzle. While Wordle uses a 3-state positional
feedback matrix (Green/Yellow/Gray), the core process of
systematically reducing the solution space is identical.
Bulls and Cows:
The traditional pen-and-paper code-breaking game dating back to the
early 20th century that served as the direct mechanical predecessor
to Mastermind.
Zebra Puzzle (Einstein's Riddle):
A classic logic grid puzzle where players deduce unknown assignments
across multiple categorical variables using a series of elimination
rules and constraints.