An Optimal Strategy for Static Black-Peg Mastermind with Three Pegs

  • Gerold JägerEmail author
  • Frank Drewes
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11059)


Mastermind is a famous game played by a codebreaker against a codemaker. We investigate its static (also called non-adaptive) black-peg variant. Given c colors and p pegs, the codemaker has to choose a secret, a p-tuple of c colors, and the codebreaker asks a set of questions all at once. Like the secret, a question is a p-tuple of c colors. The codemaker then tells the codebreaker how many pegs in each question are correct in position and color. Then the codebreaker has one final question to find the secret. His aim is to use as few of questions as possible. Our main result is an optimal strategy for the codebreaker for \(p=3\) pegs and an arbitrary number c of colors using \( \lfloor 3c/2 \rfloor +1\) questions.

A reformulation of our result is that the metric dimension of \( \mathbb {Z}_n \times \mathbb {Z}_n \times \mathbb {Z}_n\) is equal to \( \lfloor 3n/2 \rfloor \).


  1. 1.
    Blumenthal, L.M.: Theory and Applications of Distance Geometry. Clarendon Press, Oxford (1953)zbMATHGoogle Scholar
  2. 2.
    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. Discrete Math. 21(2), 423–441 (2007)MathSciNetCrossRefGoogle Scholar
  3. 3.
    Focardi, R., Luccio, F.L.: Guessing bank pins by winning a mastermind game. Theory Comput. Syst. 50(1), 52–71 (2012)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Gagneur, J., Elze, M.C., Tresch, A.: Selective phenotyping, entropy reduction and the mastermind game. BMC Bioinform. (BMCBI) 12, 406 (2011)CrossRefGoogle Scholar
  5. 5.
    Glazik, C., Jäger, G., Schiemann, J., Srivastav, A.: Bounds for static black-peg AB mastermind. In: Gao, X., Du, H., Han, M. (eds.) COCOA 2017. LNCS, vol. 10628, pp. 409–424. Springer, Cham (2017). Scholar
  6. 6.
    Goddard, W.: Static mastermind. J. Comb. Math. Comb. Comput. 47, 225–236 (2003)MathSciNetzbMATHGoogle Scholar
  7. 7.
    Goddard, W.: Mastermind revisited. J. Comb. Math. Comb. Comput. 51, 215–220 (2004)MathSciNetzbMATHGoogle Scholar
  8. 8.
    Goodrich, M.T.: On the algorithmic complexity of the mastermind game with black-peg results. Inf. Process. Lett. 109(13), 675–678 (2009)MathSciNetCrossRefGoogle Scholar
  9. 9.
    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). Scholar
  10. 10.
    Jäger, G., Peczarski, M.: The number of pessimistic guesses in Generalized Mastermind. Inf. Process. Lett. 109(12), 635–641 (2009)MathSciNetCrossRefGoogle Scholar
  11. 11.
    Jäger, G., Peczarski, M.: The number of pessimistic guesses in Generalized Black-Peg Mastermind. Inf. Process. Lett. 111(19), 933–940 (2011)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Jäger, G., Peczarski, M.: The worst case number of questions in generalized AB game with and without white-peg answers. Discrete Appl. Math. 184, 20–31 (2015)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Söderberg, S., Shapiro, H.S.: A combinatory detection problem. Am. Math. Mon. 70(10), 1066–1070 (1963)MathSciNetCrossRefGoogle Scholar
  14. 14.
    Stuckman, J., Zhang, G.Q.: Mastermind is NP-complete. INFOCOMP J. Comput. Sci. 5, 25–28 (2006)Google Scholar
  15. 15.

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  1. 1.Department of Mathematics and Mathematical StatisticsUniversity of UmeåUmeåSweden
  2. 2.Department of Computing ScienceUniversity of UmeåUmeåSweden

Personalised recommendations