Sudoku Grids That Require Many Clues

David Eppstein1 Xinyu (Cindy) Zhang
Computer Science Department, University of California, Irvine


Abstract

Motivated by worst-case algorithmic time bounds for solving sudoku, we prove that a majority of filled-in \(n^2\times n^2\) sudoku grids require all but a logarithmic fraction of cells to be filled by clues. For \(9\times 9\) and \(16\times 16\) sudoku, we construct grids that require \(18\) clues and \(80\) clues.

1 Introduction↩︎

In sudoku puzzles, a \(9\times 9\) grid of square cells, partitioned into nine \(3\times 3\) blocks, is to be filled with the digits from \(1\) to \(9\) so each row, column, and block contains each digit. To make the solution unique, some cells are initially filled as clues. Often \(30\%\)\(35\%\) of cells are clues, but many fewer can be needed: the minimum number of clues in a uniquely-solvable puzzle is \(17\). Sudoku can be generalized to \(n^2\times n^2\) grids partitioned into \(n^2\) blocks of size \(n\times n\), and \(16\times 16\) sudoku is conjectured to require \(56\) clues [1]. For \(n^2\times n^2\) sudoku the minimum number of clues is conjecturally \(\Omega(n^4)\); only \(\Omega(n^2)\) has been proven, but special clue sets that allow a solution using very restricted deduction rules require \(\Omega(n^4)\) clues. Further, some sudoku puzzles can be uniquely specified using \(\lfloor n^4/4\rfloor\) clues [2].

We study a variant of this minimum-clue problem. Instead of the fewest clues among all sudoku puzzles, we seek the fewest clues for a given filled-in grid, and a grid that maximizes this minimum number of clues. We prove that most \(n^2\times n^2\) filled grids require \(n^4-O(n^4/\log n)\) clues, leaving only a logarithmic fraction of cells unfilled. We construct many \(9\times 9\) sudoku grids requiring \(18\) clues, matching a report of McGuire et al. [1] that \(17\) clues do not always suffice, and a \(16\times 16\) grid requiring \(80\) clues, well above the conjectured \(56\)-clue minimum. Our results are motivated by the worst-case algorithmic complexity of sudoku, and by a result that an \(n^2\times n^2\) sudoku puzzle with \(m\) clues can be solved in time \(O(n^4\,2^{n^4-m})\). For this solution method, grids with more clues can be solved more quickly.

A related problem, adding the fewest clues to a partial set of clues to produce a unique solution, is hard for the second level of the polynomial hierarchy [3]. Our problem differs in seeking the fewest clues for the solution itself. It would be of interest to find its computational complexity; we do not.

2 Algorithmic motivation↩︎

Published sudoku puzzles often can be solved by deduction rules of polynomial complexity [4], but sudoku is \(\mathsf{NP}\)-hard and hence unlikely to have polynomial worst-case time [5]. Backtracking often works well but this has not been validated theoretically. To close the gap between theory and practice, we seek worst-case times that are exponential but as fast as possible. A brute force search that checks all ways of filling empty cells with digits would take time \(O(n^4 n^{2(n^2-m)})\). Instead, we adapt an algorithm by Björklund, Husfeldt, and Koivisto that uses dynamic programming and inclusion–exclusion on the lattice of subsets of a given set to find exact covers [6].

Define a valid placement of a digit to be a set of cells that, together with the clues for that digit, include one cell in each row, column, and block of the puzzle. A sudoku solution partitions all cells into valid placements, one per digit. This is not quite an exact cover because each digit must contribute exactly one valid placement to the cover. Instead we use the sum weighted partitions problem defined by Björklund et al. [6]. It takes as input a family of \(k\) functions \(f_i\) from subsets of a given set to numbers; the output is the sum of products \(\sum_P\prod_i f_i(P_i)\) where the sum is over partitions \(P\) into \(k\) sets \(P_i\). For sudoku, let \(k=n^2\) and let \(f_i(S)\) be one when \(S\) is a valid placement of digit \(i\) and zero otherwise; then the sum weighted partitions value is the number of puzzle solutions. (Conventionally this should equal one but we do not assume this.) By evaluating this number of solutions, we can determine whether any digit placement leads to a solution, and by iterating, solve the puzzle.

Theorem 1. We can solve sudoku in time \(n^{O(1)}\,2^{n^4-m}\).

Proof. We construct the functions \(f_i\) defined above by setting all subset values to zero, listing valid placements using a reduction to enumerating paths in graphs [7] and setting each placement’s value to one. We then apply the sum weighted partitions algorithm of Björklund et al., which for \(n^2\) 0–1 valued functions on subsets of \(n^4-m\) cells takes the stated time. ◻

3 Existence↩︎

We prove the existence of filled grids with many clues by comparing the number of filled grids to the number of ways of specifying clues. If \(S(n)\) denotes the number of filled \(n^2\times n^2\) sudoku grids, then only \(S(2)=288\) and \[S(3)=6\,670\,903\,752\,021\,072\,936\,960\] are known exactly [8]. Asymptotically, Keevash [9] proves that \[S(n)=\left(\frac{n^2}{e^3}+o(n^2)\right)^{n^4}.\] If \(C(n,m)\) denotes the number of ways of specifying \(m\) clues in an \(n^2\times n^2\) sudoku grid, then \[C(n,m)\le\binom{n^4}{m}n^{2m},\] for there are \(\tbinom{n^4}{m}\) choices of clue placements and \((n^2)^m=n^{2m}\) ways of filling them with digits. At most \(C(n,m)\) filled grids can be determined by these \(m\) clues. It does not increase the count of grids to include puzzles with fewer clues, because such a puzzle could be extended to exactly \(m\) clues by adding unnecessary clues. Comparing \(S(n)\) and \(C(n,m)\) gives our result:

Theorem 2. All but a \(1/2^{n^4}\) fraction of the filled \(n^2\times n^2\) sudoku grids require \(m\ge n^4-O(n^4/\log n)\) clues.

Proof. We need \(C(n,m)\ge S(n)/2^{n^4}\) to represent more than a \(1/2^{n^4}\) fraction of the filled grids. Taking logarithms (base \(2\)) of both sides, and using the fact that \(\tbinom{n^4}{m}\le 2^{n^4}\), gives \[n^4+2m\log_2 n \ge 2n^4\log_2 n-(3\log_2 e+1)n^4+o(n^4).\] Subtracting \(n^4\) from both sides, dividing by \(2\log_2 n\), and consolidating the lower-order terms gives the stated bound. ◻

As each filled grid has at least one minimal clue set, the same counting argument shows that the same fraction of minimal clue sets require the same number of clues. This leads to a better exponent in the exponential-time algorithms for these puzzles:

Corollary 1. For all but a \(1/2^{n^4}\) fraction of filled \(n^2\times n^2\) sudoku grids or minimal sudoku clue sets, solving a puzzle with this solution or clue set takes time \(2^{O(n^4/\log n)}\). The same time bound holds in the average case over random filled grids or minimal clue sets.

4 Construction↩︎

A Latin square is like a sudoku grid in having distinct digits in each row or column of its grid of cells, but its side length need not be square and its cells are not grouped into blocks. The following steps pack \(n^2\) Latin squares of size \(n\times n\) into an \(n^2\times n^2\) sudoku grid:

  • Partition the \(n^2\) digits into \(n\) subsets \(D_i\) of \(n\) digits. In the filled sudoku grid, each row of each block will use one of these subsets.

  • For each of \(n\) horizontal groups of \(n\times n\) sudoku blocks, use an \(n\times n\) Latin square to determine which row of each block uses which digit subset \(D_i\).

  • For each of \(n\) vertical groups of \(n\times n\) sudoku blocks, and each subset \(D_i\) of digits, place \(D_i\) into its assigned rows (an \(n\times n\) subset of cells) as an \(n\times n\) Latin square.

Let \(L(n)\) denote the number of \(n\times n\) Latin squares. There are \(n^2!/n!^{n+1}\) partitions of digits into subsets \(D_i\) (treating any permutation of subsets as equivalent), \(L(n)^n\) ways of choosing Latin squares for horizontal groups of blocks, and \(L(n)^{n^2}\) ways of choosing Latin squares for digit subsets in each vertical group of blocks. Thus, the total number of choices is \[\frac{n^2!}{n!^{n+1}}L(n)^{n^2+n}.\]

\(L(3)=12\), so this formula gives \(2\,496\,508\,125\,511\,680\) distinct \(9\times 9\) sudoku grids, each packed with nine \(3\times 3\) Latin squares. Each Latin square requires two clues, because a single clue would allow swapping the other two digits in that square. Thus, each of these sudoku grids requires at least \(18\) clues.

For \(n=4\), case analysis shows that the Latin square \[\begin{matrix} 1 & 2 & 3 & 4 \\ 2 & 1 & 4 & 3 \\ 3 & 4 & 1 & 2 \\ 4 & 3 & 2 & 1 \\ \end{matrix}\] requires five clues. Using our construction to pack \(16\) copies of this Latin square into a \(16\times 16\) sudoku grid produces a filled grid requiring \(80\) clues.

Hatami and Qian [10] prove that all \(n\times n\) Latin squares require \(\Omega(n^2)\) clues, so in general the sudoku grids from our construction require \(\Omega(n^4)\) clues.

References↩︎

[1]
G. McGuire, B. Tugemann, and G. Civario. There is no 16-clue sudoku: Solving the sudoku minimum number of clues problem via hitting set enumeration. Exp. Math., 23:190–217, 2014. https://doi.org/10.1080/10586458.2013.870056.
[2]
M. Mahdian and E. S. Mahmoodian. Small defining sets in \(n\times n\) sudoku squares. In Proc. 7th Internat. Conf. on Computational Methods (ICCM), pages 1292–1298, 2016. URL: https://www.sci-en-tech.com/ICCM2016/PDFs/2006-6313-1-PB.pdf.
[3]
E. D. Demaine, F. Ma, A. Schvartzman, E. Waingarten, and S. Aaronson. The fewest clues problem. Theoret. Comput. Sci., 748:28–39, 2018. https://doi.org/10.1016/j.tcs.2018.01.020.
[4]
D. Eppstein. . Preprint, 2005. URL: https://arxiv.org/abs/cs.DS/0507053.
[5]
T. Yato and T. Seta. . Trans. IEICE, E86-A(5):10521060, 2003.
[6]
A. Björklund, T. Husfeldt, and M. Koivisto. Set partitioning via inclusion-exclusion. SIAM J. Comput., 39(2):546–563, 2009. https://doi.org/10.1137/070683933.
[7]
D. Eppstein. Solving single-digit sudoku subproblems. In Proc. 6th Internat. Conf. Fun with Algorithms, volume 7288 of Lecture Notes in Comp. Sci., pages 142–153. Springer, 2012. https://doi.org/10.1007/978-3-642-30347-0_16.
[8]
OEIS contributors. . In Online Encyc. Integer Sequences. OEIS Foundation, February 11, 2026. URL: https://oeis.org/A107739.
[9]
P. Keevash. . In I. Bárány, G. Katona, and A. Sali, editors, Building Bridges II: Mathematics of László Lovász, volume 28 of Bolyai Soc. Math. Studies, pages 279315. Springer, 2019. https://doi.org/10.1007/978-3-662-59204-5_9.
[10]
H. Hatami and Y. Qian. Teaching dimension, VC dimension, and critical sets in Latin squares. J. Comb., 9(1):9–20, 2018. https://doi.org/10.4310/JOC.2018.v9.n1.a2.

  1. Research supported in part by NSF grant CCF-2212129.↩︎