English

Playing Mastermind with Many Colors

Data Structures and Algorithms 2013-01-18 v2 Discrete Mathematics

Abstract

We analyze the general version of the classic guessing game Mastermind with nn positions and kk colors. Since the case kn1εk \le n^{1-\varepsilon}, ε>0\varepsilon>0 a constant, is well understood, we concentrate on larger numbers of colors. For the most prominent case k=nk = n, our results imply that Codebreaker can find the secret code with O(nloglogn)O(n \log \log n) guesses. This bound is valid also when only black answer-pegs are used. It improves the O(nlogn)O(n \log n) bound first proven by Chv\'atal (Combinatorica 3 (1983), 325--329). We also show that if both black and white answer-pegs are used, then the O(nloglogn)O(n \log\log n) bound holds for up to n2loglognn^2 \log\log n colors. These bounds are almost tight as the known lower bound of Ω(n)\Omega(n) shows. Unlike for kn1εk \le n^{1-\varepsilon}, simply guessing at random until the secret code is determined is not sufficient. In fact, we show that an optimal non-adaptive strategy (deterministic or randomized) needs Θ(nlogn)\Theta(n \log n) guesses.

Cite

@article{arxiv.1207.0773,
  title  = {Playing Mastermind with Many Colors},
  author = {Benjamin Doerr and Carola Doerr and Reto Spöhel and Henning Thomas},
  journal= {arXiv preprint arXiv:1207.0773},
  year   = {2013}
}

Comments

Extended abstract appeared in SODA 2013. This full version has 22 pages and 1 picture

R2 v1 2026-06-21T21:29:57.650Z