Mastermind is NP-Complete: Mastermind satisfiability is NP-completeResearch Paper
From feedback to a decision problem
A Mastermind player sees guesses and feedback but cannot inspect the hidden sequence of colors. Before asking which guess to make next, one can ask whether the observations are consistent with any sequence at all. This is the Mastermind satisfiability problem, or MSP. It separates the logical content of the observations from the strategic problem of choosing informative guesses. In their 2005 preprint, Stuckman and Zhang study this decision problem and state that it is NP-complete. The question concerns arbitrarily large boards and alphabets, rather than one commercial game's fixed configuration.
The input is an entire finite collection of observations. Each observation names a guess and its prescribed response. The answer is YES precisely when one hidden sequence explains every observation simultaneously. A transcript need not have arisen from an actual game: inconsistent transcripts are part of the decision problem and must receive the answer NO.
Codes, repeated colors, and scores
Fix a number of colors and a sequence length . A code is an ordered sequence of colors; repetitions are allowed. A guess has the same form. For two codes , the black score counts positions containing the same color in both sequences. Let be the number of occurrences of color in . The total number of color matches, respecting multiplicity but ignoring position, is
The feedback is the pair
Its second component counts the white pegs, which represent matching colors not already counted as black pegs. For example, guesses and have score ; sequences and have score . Counting only distinct colors would give the wrong model.
An instance consists of these parameters and a finite set of guesses, each with one prescribed feedback pair. It is satisfiable when there is a single code such that every guess has precisely its prescribed score against . Neither uniqueness nor prior consistency is assumed. This is the model in Definition 2.1 and §2.1.
Formalization target
Write for the binary language of satisfiable instances with , and for the sublanguage whose encoded color count is exactly . The goal states the two claims together:
NP-completeness includes both membership in NP and hardness under polynomial-time many-one reductions from every NP language. The assertion is unconditional: it assumes neither that P differs from NP nor that a suitable reduction has already been constructed. There is no global bound on the sequence length or number of guesses.
The fixed-color clause retains the stronger reading of the preamble to Theorem 2.1, page 4, which says “for κ > 1.” The printed proof uses a growing color alphabet and therefore does not itself establish this stronger scope. That proof gap is recorded separately; it is not an extra premise of the goal. There are no supporting source milestones in this mission.
What the result establishes
The theorem places consistency of Mastermind feedback among problems that admit short, efficiently checkable certificates and encode the difficulty of every NP problem. It concerns finding whether an explanation exists, rather than efficiently identifying a unique explanation or optimizing a playing strategy. Distinguishing these questions matters because they have different inputs and conclusions.
A formal development makes the score conventions, the quantification over transcripts, and the computational interpretation of input size explicit. The present goal is a statement awaiting proof. Its definitions are concrete, and its complexity notions reuse the published CookPvsNP machine model. The source's independent metric proposition and uniqueness discussion do not appear as assumptions or milestones. Their transcription issues are recorded in the accompanying source findings.
Where the difficulty lies
Trying every hidden code establishes only that each finite instance can be decided. The number of candidates grows exponentially in the board length, so this observation does not establish the required complexity classification. Conversely, rapidly evaluating a proposed code addresses only verification; it says nothing by itself about universal hardness.
The fixed-color claim introduces an additional issue: a construction that increases the alphabet with its input does not automatically settle the problem for two colors or for another prescribed alphabet size. The full statement retains that obligation. Also, the number of guesses is unbounded, so complexity cannot be measured by board length alone while ignoring the cost of reading the transcript.
Formalization scope and encoding
Codes use Fin ℓ → Fin κ, relabeling the source's one-based colors and positions by subtracting one. Empty sequences are permitted. Feedback uses natural numbers; negative feedback has no valid encoding, while impossible nonnegative feedback remains representable and unsatisfiable. Matching-coordinate counts implement the intended reading of the shadowed index in Definition 2.1, as explained by the surrounding text.
A finite guess set is represented by strictly lexicographically increasing rows. This gives one score per guess and rejects duplicates, including conflicting duplicates. Every integer is encoded by canonical little-endian binary digits preceded by their unary digit count and a false separator. Zero has one false digit. The complete string contains the color count, board length, row count, then every color and feedback entry in row order. Membership requires equality with a complete encoding, so extra trailing data and malformed encodings are rejected.
Running time is measured in the length of this complete binary string. An empty transcript can describe a large board compactly and is always satisfiable when ; it must not force an exponentially long certificate. For nonempty transcripts, a written guess already contains all positions. The mathematical score sums over colors, but the eventual verification algorithm must avoid enumerating exponentially many unused colors. These are proof obligations, not restrictions on instances. No consistency promise or special family of generated instances is hidden in the definitions.
Selected references
- Jeff Stuckman and Guo-Qiang Zhang, Mastermind is NP-Complete, preprint, 2005, arXiv:cs/0512049v1, Definition 2.1 and Theorem 2.1.