The Query Complexity of Mastermind with l_p Distances

Authors Manuel Fernández V, David P. Woodruff, Taisuke Yasuda

Thumbnail PDF


  • Filesize: 0.52 MB
  • 11 pages

Document Identifiers

Author Details

Manuel Fernández V
  • Computer Science Department, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA
David P. Woodruff
  • Computer Science Department, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA
Taisuke Yasuda
  • Department of Mathematics, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA


We thank Flavio Chierichetti and Ravi Kumar for helpful discussions, as well as the anonymous reviewers for helpful feedback.

Cite AsGet BibTex

Manuel Fernández V, David P. Woodruff, and Taisuke Yasuda. The Query Complexity of Mastermind with l_p Distances. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM 2019). Leibniz International Proceedings in Informatics (LIPIcs), Volume 145, pp. 1:1-1:11, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2019)


Consider a variant of the Mastermind game in which queries are l_p distances, rather than the usual Hamming distance. That is, a codemaker chooses a hidden vector y in {-k,-k+1,...,k-1,k}^n and answers to queries of the form ||y-x||_p where x in {-k,-k+1,...,k-1,k}^n. The goal is to minimize the number of queries made in order to correctly guess y. In this work, we show an upper bound of O(min{n,(n log k)/(log n)}) queries for any real 1<=p<infty and O(n) queries for p=infty. To prove this result, we in fact develop a nonadaptive polynomial time algorithm that works for a natural class of separable distance measures, i.e., coordinate-wise sums of functions of the absolute value. We also show matching lower bounds up to constant factors, even for adaptive algorithms for the approximation version of the problem, in which the problem is to output y' such that ||y'-y||_p <= R for any R <= k^{1-epsilon}n^{1/p} for constant epsilon>0. Thus, essentially any approximation of this problem is as hard as finding the hidden vector exactly, up to constant factors. Finally, we show that for the noisy version of the problem, i.e., the setting when the codemaker answers queries with any q = (1 +/- epsilon)||y-x||_p, there is no query efficient algorithm.

Subject Classification

ACM Subject Classification
  • Mathematics of computing → Combinatorics
  • Theory of computation → Design and analysis of algorithms
  • Mastermind
  • Query Complexity
  • l_p Distance


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Peyman Afshani, Manindra Agrawal, Benjamin Doerr, Carola Doerr, Kasper Green Larsen, and Kurt Mehlhorn. The query complexity of a permutation-based variant of Mastermind. Discrete Applied Mathematics, 2019. Google Scholar
  2. Aaron Berger, Christopher Chute, and Matthew Stone. Query complexity of mastermind variants. Discrete Mathematics, 341(3):665-671, 2018. Google Scholar
  3. Nader H. Bshouty. Optimal Algorithms for the Coin Weighing Problem with a Spring Scale. In COLT 2009 - The 22nd Conference on Learning Theory, Montreal, Quebec, Canada, June 18-21, 2009, 2009. URL:
  4. Vasek Chvátal. Mastermind. Combinatorica, 3(3):325-329, 1983. URL:
  5. Benjamin Doerr, Carola Doerr, Reto Spöhel, and Henning Thomas. Playing Mastermind With Many Colors. J. ACM, 63(5):42:1-42:23, 2016. URL:
  6. David Ginat. Digit-distance Mastermind. The Mathematical Gazette, 86(507):437-442, 2002. Google Scholar
  7. Donald E. Knuth. The computer as a master mind. Journal of Recreational Mathematics, 9:1-6, 1977. Google Scholar
  8. Xianfu Wang. Volumes of generalized unit balls. Mathematics Magazine, 78(5):390-395, 2005. Google Scholar
  9. Andrew Chi-Chin Yao. Probabilistic computations: Toward a unified measure of complexity. In Proceedings of the 18th Annual IEEE Symposium on Foundations of Computer Science, pages 222-227. IEEE, 1977. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail