Bounds for Static Black-Peg AB Mastermind

  • Christian Glazik
  • Gerold JägerEmail author
  • Jan Schiemann
  • Anand Srivastav
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10628)


Mastermind is a famous two-player game introduced by M. Meirowitz (1970). Its combinatorics has gained increased interest over the last years for different variants.

In this paper we consider a version known as the Black-Peg AB Game, where one player creates a secret code consisting of c colors on \(p \le c\) pegs, where each color is used at most once. The second player tries to guess the secret code with as few questions as possible. For each question he receives the number of correctly placed colors. In the static variant the second player doesn’t receive the answers one at a time, but all at once after asking the last question. There are several results both for the AB and the static version, but the combination of both versions has not been considered so far. The most prominent case is \(n:=p=c\), where the secret code and all questions are permutations. The main result of this paper is an upper bound of \(\mathcal {O}(n^{1.525})\) questions for this setting. With a slight modification of the arguments of Doerr et al. (2016) we also give a lower bound of \(\varOmega (n\log n)\). Furthermore, we complement the upper bound for \(p=c\) by an optimal \((\lceil 4c/3 \rceil -1)\)-strategy for the special case \(p=2\) and arbitrary \(c\ge 2\) and list optimal strategies for six additional pairs (pc) .



The second author’s research was supported by the Kempe Foundation Grant No. SMK-1354 (Sweden).

Furthermore, we would like to thank the anonymous referees for their valuable comments which significantly helped to improve the paper.


  1. 1.
    Asuncion, A.U., Goodrich, M.T.: Nonadaptive mastermind algorithms for string and vector databases, with case studies. IEEE Trans. Knowl. Data Eng. 25(1), 131–144 (2013)CrossRefGoogle Scholar
  2. 2.
    Baker, R.C., Harman, G., Pintz, J.: The difference between consecutive primes II. Proc. Lond. Math. Soc. 83(3), 532–632 (2001)CrossRefzbMATHMathSciNetGoogle Scholar
  3. 3.
    Cáceres, J., Hernando, C., Mora, M., Pelayo, I.M., Puertas, M.L., Seara, C., Wood, D.R.: On the metric dimension of cartesian products of graphs. SIAM J. Discret. Math. 21(2), 423–441 (2007)CrossRefzbMATHMathSciNetGoogle Scholar
  4. 4.
    Doerr, B., Doerr, C., Spöhel, R., Thomas, H.: Playing Mastermind With Many Colors. J. ACM 63(5), 42:1–42:23 (2016). ACMCrossRefMathSciNetGoogle Scholar
  5. 5.
    El Ouali, M., Glazik, C., Sauerland, V., Srivastav, A.: On the query complexity of black-peg AB-mastermind. CoRR, abs/1611.05907 2016)
  6. 6.
    Focardi, R., Luccio, F.L.: Guessing bank PINs by winning a mastermind game. Theory Comput. Syst. 50(1), 52–71 (2012)CrossRefzbMATHMathSciNetGoogle Scholar
  7. 7.
    Fort, M.K., Hedlund, G.A.: Minimal coverings of pairs by triples. Pac. J. Math. 8(4), 709–719 (1958)CrossRefzbMATHMathSciNetGoogle Scholar
  8. 8.
    Jäger, G.: An optimal strategy for static black-peg mastermind with two pegs. In: Chan, T.-H.H., Li, M., Wang, L. (eds.) COCOA 2016. LNCS, vol. 10043, pp. 670–682. Springer, Cham (2016). CrossRefGoogle Scholar
  9. 9.
    Jäger, G., Peczarski, M.: The number of pessimistic guesses in generalized mastermind. Inf. Process. Lett. 109(12), 635–641 (2009)CrossRefzbMATHMathSciNetGoogle Scholar
  10. 10.
    Jäger, G., Peczarski, M.: The number of pessimistic guesses in generalized black-peg mastermind. Inf. Process. Lett. 111(19), 933–940 (2011)CrossRefzbMATHMathSciNetGoogle Scholar
  11. 11.
    Jäger, G., Peczarski, M.: The worst case number of questions in generalized AB game with and without white-peg answers. Discret. Appl. Math. 184, 20–31 (2015)CrossRefzbMATHMathSciNetGoogle Scholar
  12. 12.
    Riordan, J.: Introduction to Combinatorial Analysis. Dover Books on Mathematics. Dover Publications, New York (2002)Google Scholar
  13. 13.
    Schrijver, A.: Combinatorial Optimization: Polyhedra and Efficiency. Algorithms and Combinatorics, 1st edn. Springer, Heidelberg (2003)zbMATHGoogle Scholar
  14. 14.
    Stuckman, J., Zhang, G.Q.: Mastermind is NP-complete. INFOCOMP J. Comput. Sci. 5(2), 25–28 (2006)Google Scholar
  15. 15.
    Source Code of the Computer Program of this Article.

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  • Christian Glazik
    • 1
  • Gerold Jäger
    • 2
    Email author
  • Jan Schiemann
    • 1
  • Anand Srivastav
    • 1
  1. 1.Department of Computer ScienceKiel UniversityKielGermany
  2. 2.Department of Mathematics and Mathematical StatisticsUniversity of UmeåUmeåSweden

Personalised recommendations