Hostname: page-component-77f85d65b8-g4pgd Total loading time: 0 Render date: 2026-03-28T20:42:04.150Z Has data issue: false hasContentIssue false

Mastermind with a linear number of queries

Published online by Cambridge University Press:  08 November 2023

Anders Martinsson*
Affiliation:
Department of Computer Science, ETH Zurich, Zurich, Switzerland
Pascal Su
Affiliation:
Department of Computer Science, ETH Zurich, Zurich, Switzerland
*
Corresponding author: Anders Martinsson; Email: anders.martinsson@inf.ethz.ch
Rights & Permissions [Opens in a new window]

Abstract

Since the 1960s Mastermind has been studied for the combinatorial and information-theoretical interest the game has to offer. Many results have been discovered starting with Erdős and Rényi determining the optimal number of queries needed for two colours. For $k$ colours and $n$ positions, Chvátal found asymptotically optimal bounds when $k \le n^{1-\varepsilon }$. Following a sequence of gradual improvements for $k\geq n$ colours, the central open question is to resolve the gap between $\Omega (n)$ and $\mathcal{O}(n\log \log n)$ for $k=n$. In this paper, we resolve this gap by presenting the first algorithm for solving $k=n$ Mastermind with a linear number of queries. As a consequence, we are able to determine the query complexity of Mastermind for any parameters $k$ and $n$.

Information

Type
Paper
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
Copyright
© The Author(s), 2023. Published by Cambridge University Press
Figure 0

Algorithm 1: Permutation

Figure 1

Figure 1. Information Tree for $n= 8$. Every node corresponds to an interval, here marked in red.

Figure 2

Figure 2. Example configuration for $n= 8$. Tokens of colours $1$ through $8$ are at different positions in the information tree and there are four remaining possibilities for the codeword.

Figure 3

Algorithm 2: Preprocess(T)

Figure 4

Figure 3. Tree preprocessed for n = 32, all black vertices have been emptied, tokens are at red vertices.

Figure 5

Algorithm 3: Solve(T)