Theory of Computing Systems

, Volume 55, Issue 4, pp 658–684 | Cite as

Playing Mastermind with Constant-Size Memory

  • Benjamin Doerr
  • Carola Winzen


We analyze the classic board game of Mastermind with n holes and a constant number of colors. The classic result of Chvátal (Combinatorica 3:325–329, 1983) states that the codebreaker can find the secret code with Θ(n/logn) questions. We show that this bound remains valid if the codebreaker may only store a constant number of guesses and answers. In addition to an intrinsic interest in this question, our result also disproves a conjecture of Droste, Jansen, and Wegener (Theory Comput. Syst. 39:525–544, 2006) on the memory-restricted black-box complexity of the OneMax function class.


Mastermind Query complexity Memory-restricted algorithms 


  1. 1.
    Anil, G., Wiegand, R.P.: Black-box search by elimination of fitness functions. In: Proc. of Foundations of Genetic Algorithms (FOGA’09), pp. 67–78. ACM, New York (2009) Google Scholar
  2. 2.
    Chen, Z., Cunha, C., Homer, S.: Finding a hidden code by asking questions. In: Proc. of the Second Annual International Conference on Computing and Combinatorics (COCOON’96). Lecture Notes in Computer Science, vol. 1090, pp. 50–55. Springer, Berlin (1996) Google Scholar
  3. 3.
    Vasek, C.: Mastermind. Combinatorica 3, 325–329 (1983) MathSciNetCrossRefGoogle Scholar
  4. 4.
    Droste, S., Jansen, T., Wegener, I.: Upper and lower bounds for randomized search heuristics in black-box optimization. Theory Comput. Syst. 39, 525–544 (2006) MathSciNetCrossRefMATHGoogle Scholar
  5. 5.
    Doerr, B., Winzen, C.: Memory-restricted black-box complexity of OneMax. Inf. Process. Lett. 112, 32–34 (2012) MathSciNetCrossRefMATHGoogle Scholar
  6. 6.
    Doerr, B., Winzen, C.: Playing Mastermind with constant-size memory. In: Proc. of the Symposium on Theoretical Aspects of Computer Science (STACS’12), LIPIcs, vol. 14, pp. 441–452 (2012). Schloss Dagstuhl—Leibniz-Zentrum fuer Informatik Google Scholar
  7. 7.
    Erdős, P., Rényi, A.: On two problems of information theory. Magy. Tud. Akad. Mat. Kut. Intéz. Közl. 8, 229–243 (1963) Google Scholar
  8. 8.
    Goodrich, M.T.: On the algorithmic complexity of the mastermind game with black-peg results. Inf. Process. Lett. 109, 675–678 (2009) MathSciNetCrossRefMATHGoogle Scholar
  9. 9.
    Jäger, G., Peczarski, M.: The number of pessimistic guesses in generalized black-peg Mastermind. Inf. Process. Lett. 111, 933–940 (2011) CrossRefMATHGoogle Scholar
  10. 10.
    Knuth, D.E.: The computer as a master mind. J. Recreat. Math. 9, 1–5 (1977) MathSciNetMATHGoogle Scholar
  11. 11.
    Motwani, R., Raghavan, P.: Randomized Algorithms. Cambridge University Press, Cambridge (1995) CrossRefMATHGoogle Scholar
  12. 12.
    Stuckman, J., Zhang, G.-Q.: Mastermind is NP-complete. INFOCOMP J. Comput. Sci. 5, 25–28 (2006) Google Scholar
  13. 13.
    Wegener, I.: Simulated annealing beats metropolis in combinatorial optimization. In: Proc. of the 32nd International Colloquium on Automata, Languages and Programming (ICALP’05). Lecture Notes in Computer Science, vol. 3580, pp. 589–601. Springer, Berlin (2005) CrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2012

Authors and Affiliations

  • Benjamin Doerr
    • 1
  • Carola Winzen
    • 1
  1. 1.D1: Algorithms and ComplexityMax Planck Institute for InformaticsSaarbrückenGermany

Personalised recommendations