
ADSP: Algorithms + Data Structures = Programs Episode 271: Mastermind Algorithms
Jan 30, 2026
A deep dive into algorithms that solve Mastermind through clever transforms and counts. Discussion of exact vs near match computations and links to Wordle-style feedback. Exploration of zip-style element-wise operations, frequency and outer-product counting, and adjacent-transform techniques. A neat use of array-language inverse operators and un-plus-scan to produce miss, near, and exact counts.
AI Snips
Chapters
Transcript
Episode notes
Mastermind Mirrors Wordle Feedback
- Mastermind gives identical feedback to Wordle: exact (green) and near (yellow) matches.
- Conor Hoekstra maps colors to numbers and frames computation as exact and near match algorithms.
Exact Matches As Zip+Sum
- Exact matches are computed by element-wise equality followed by a sum.
- This is implemented with a two-range transform (zip transform) then an accumulation or fold.
Near Matches Via Frequency Intersection
- Naive near-match computation removes exact matches then counts frequencies.
- Alternatively, use outer products or frequency arrays and element-wise minima across symbol counts.
