---
title: 'Queens: Combinatorics and Algorithmics'
url: https://www.emergentmind.com/topics/queens
type: topic
---

# Queens: Combinatorics and Algorithmics

Queens, in combinatorics and algorithmics, denotes a family of chessboard placement problems defined by the queen attack relation—common row, common column, or common diagonal. The central object is the \(n\)-queens problem: place \(n\) mutually non-attacking queens on an \(n\times n\) board, or count how many such placements exist. The same attack primitive also underlies toroidal, reflecting, Toeplitz, infinite-board, higher-dimensional, completion, coverage, and peaceability variants, together with graph-theoretic, probabilistic, spectral, and optimization formulations [2109.08083][2406.06974][2407.12742].

## 1. Classical and toroidal formulations

On the classical \(n\times n\) board, a queen at \((x,y)\) attacks any square \((x',y')\) with \(x'=x\), \(y'=y\), \(x'+y'=x+y\), or \(x'-y'=x-y\). A partial configuration is a set \(Q\subseteq [n]^2\) with at most one queen in each row, column, and non-toroidal diagonal; an \(n\)-queens configuration is a partial configuration of size \(n\) [2105.11431].

A standard encoding uses a permutation \(\sigma\in S_n\), where row \(i\) contains a queen in column \(\sigma(i)\). The row and column constraints are then automatic, and the remaining obstruction is diagonal collision. Formally, a classical solution is a \(\sigma\in S_n\) for which all values \(i+\sigma(i)\) and \(i-\sigma(i)\) are distinct. This permutation viewpoint is central both to asymptotic counting and to probabilistic algorithms [2109.08083].

The toroidal variant replaces the board by a torus: rows and columns are indexed modulo \(n\), and both diagonal families wrap around modulo \(n\). There are exactly \(n\) toroidal diagonals of each type, all of size \(n\). A toroidal configuration is therefore a permutation \(\sigma\in S_n\) such that the residues \(i+\sigma(i)\pmod n\) are all distinct and the residues \(i-\sigma(i)\pmod n\) are all distinct [2105.11431].

This modular structure admits a hypergraph formulation. A toroidal configuration is exactly a perfect matching in a natural \(4\)-partite, \(4\)-uniform hypergraph \(\mathcal{T}(n)\) with parts \(X,Y,X+Y,X-Y\), each of size \(n\), whose edges are quadruples \((i,j,i+j \bmod n,i-j \bmod n)\). The classical problem similarly corresponds to matchings in a related non-regular hypergraph \(\mathcal{Q}(n)\) with non-wrapping diagonal parts of size \(2n-1\) [2109.08083].

## 2. Existence theorems and early milestones

The classical existence theory is elementary only at a coarse level. The values \(Q(0)=Q(1)=1\) are trivial, and classical solutions exist for all \(n\ge 4\). Historically, \(Q(8)=92\) was found by Nauck in 1850 and proved by Glaisher and Pauls in 1874; values of \(Q(n)\) are tabulated up to \(n=27\) in OEIS A000170 [2109.08083].

The toroidal existence criterion is much sharper. Pólya proved in 1918 that
\[
T(n)>0 \iff n\equiv 1,5 \pmod 6.
\]
Thus toroidal feasibility is governed by a complete congruence obstruction, unlike the classical board [2109.08083].

Several other queen models exhibit distinct arithmetic thresholds. On a symmetric \(n\times n\) Toeplitz matrix \(T_n=(|i-j|)\), where queens attack by row, column, or equal Toeplitz value \(|i-j|\), \(n\) nonattacking queens can be placed if and only if \(n\equiv 0,1\pmod 4\). In the same model, \(n-1\) nonattacking queens can be placed for every \(n\) [1007.5350].

Reflecting queens provide another existence theory. On an \(n\times n\) board with a \(1\times n\) reflecting strip attached along one side, diagonal paths may reflect via the strip. Klarner’s reflecting \(n\)-queens problem is equivalent to Slater’s number-theoretic pairing problem, and reflecting \(n\)-queens configurations exist for all sufficiently large \(n\). Small nonexistence is known for \(n=2,3,6\); existence was constructed for \(n=4,5,7,8\), and computationally for \(n=9,\dots,27\) [2407.12742].

## 3. Asymptotic enumeration

The modern counting theory separates the classical count \(Q(n)\) from the toroidal count \(T(n)\). Rivin, Vardi, and Zimmerman conjectured that
\[
\log Q(n)=\Theta(n\log n),\qquad \log T(n)=\Theta(n\log n)
\]
on the Pólya residue classes for the toroidal problem. Luria proved the first general asymptotic upper bounds:
\[
T(n)\le ((1+o(1))\,n e^{-3})^n,\qquad
Q(n)\le ((1+o(1))\,n e^{-c})^n
\]
with \(c\approx 1.587\), and conjectured that the toroidal upper bound is tight when \(n\equiv 1,5\pmod 6\) [1705.05225].

Bowtell and Keevash proved that conjecture. For the toroidal problem,
\[
T(n)=\left((1+o(1))\frac{n}{e^3}\right)^n
\quad\text{when } n\equiv 1,5\pmod 6,
\]
and \(T(n)=0\) otherwise. They also proved
\[
Q(n)\ge \left((1+o(1))\frac{n}{e^3}\right)^n
\]
for all sufficiently large \(n\). Their proof combines a random greedy algorithm with randomized algebraic construction and iterative absorption, phrased in the language of hypergraph matchings [2109.08083].

For the classical problem, the constant \(3\) is not the final answer. Simkin proved that there exists a constant \(\alpha\) with \(1.94<\alpha<1.9449\) and \(\alpha=1.942\pm 3\times 10^{-3}\) such that
\[
\mathcal{Q}(n)=\big((1\pm o(1))\,n\,e^{-\alpha}\big)^n.
\]
The proof introduces limit objects called queenons, defines a strictly concave entropy functional \(H_q\) on the compact convex set of queenons, and identifies \(\alpha\) by the variational principle \(\alpha=-\max_{\gamma\in\Gamma}H_q(\gamma)\) [2107.13460].

The toroidal constant \(e^{-3}\) admits a heuristic interpretation. Starting from \(n!\) permutations, the two diagonal families are approximately collision-free with probability about \(e^{-1}\) each, and a further joint constraint contributes a third \(e^{-1}\) factor, suggesting \((n/e^3)^n\). Bowtell–Keevash formalize the lower bound, while Luria’s entropy argument formalizes the matching upper bound [2109.08083].

## 4. Completion, construction, and computation

The \(n\)-queens completion problem asks whether a given partial non-attacking configuration can be extended to a full \(n\)-queens configuration. Let \(qc(n)\) be the largest \(k<n\) such that every placement of \(k\) mutually non-attacking queens is completable. Glock, Munhá Correia, and Sudakov proved that, for all sufficiently large \(n\),
\[
\frac{n}{60}\le qc(n)\le \frac{n}{4}.
\]
The lower bound uses rainbow matchings in bipartite graphs, probabilistic sparsification, and a generalized rainbow matching lemma; the upper bound comes from explicit non-completable partial configurations and a linear-programming dual line-weighting certificate [2111.11402].

That upper bound was improved in 2026. For all sufficiently large \(n\),
\[
qc(n)\le 0.216\,n.
\]
The improvement preserves the line-weighting method but refines the covering construction for the unattacked squares of a carefully chosen partial configuration [2606.24400].

For direct construction of full configurations, a simple two-stage randomized algorithm gives a strong lower bound for the classical counting problem. Stage 1 runs a toroidal random greedy process up to
\[
T=\lfloor (1-n^{-\alpha})\,n\rfloor,\qquad \alpha=10^{-4},
\]
and with high probability places \((1-o(1))n\) queens while maintaining dynamic concentration
\[
S_\ell(t)=n\,p(t)^3\pm \varepsilon(t),\qquad
|A(t)|=n^2p(t)^4\pm n\,p(t)\,\varepsilon(t),
\]
for \(p(t)=1-t/n\). Stage 2 uses absorbers to convert the partial toroidal configuration into a full classical one, yielding
\[
N(n)\ge \big((1-o(1))\,n e^{-3}\big)^n
\]
[2105.11431].

Optimization-oriented computation has produced different objective variants. Integer programming models with row, column, and diagonal constraints were used to compute many new lexicographically optimal solutions for \(n=56,\dots,115\), and a lexicographic bottleneck “most beautiful” variant was solved up to \(n=176\) [1907.08246]. A separate Monte Carlo line of work reformulates counting as a rare-event problem, uses quantile re-ordering based on the Lorenz curve, and combines vertical-likelihood Monte Carlo, importance sampling, simulated annealing, nested sampling, and a Swendsen–Wang style algorithm for sampling binary matrices [2407.08830].

## 5. Structural abstractions

Several structural formalisms organize the queens literature beyond direct board combinatorics. For fixed \(q\) identical queens on a dilated rational convex polygon \(S\), inside-out Ehrhart theory implies that the number \(a_q(n)\) of nonattacking placements is a quasipolynomial in \(n\) of degree \(2q\). Its leading coefficient is \((\operatorname{vol} S)^q/q!\), and reciprocity identifies \(a_q(-1)\) with the number of unlabelled combinatorial configuration types. The exact formula is indexed by the intersection semilattice of attack hyperplanes and a slope matroid of weighted graphs [1303.1879].

The asymptotic theory of the classical problem introduces queenons, which are probability measures on \([-\tfrac12,\tfrac12]^2\) with uniform marginals and sub-uniform diagonal marginals. They extend permutons by encoding diagonal sparsity. The count of configurations approximating a fixed queenon is controlled by an entropy functional involving Kullback–Leibler divergence of the measure itself and of its diagonal pushforwards, and a large deviations principle shows that typical large \(n\)-queens configurations concentrate near the unique entropy maximizer [2107.13460].

A distinct structural notation appears in graph theory: the \(n\)-Queens’ graph \(Q(n)\) has the \(n\times n\) board’s squares as vertices, with two vertices adjacent when the corresponding squares share a row, a column, or a diagonal. This graph decomposes as the sum of block-structured matrices coming from two triangular queen graphs \(T(n)\) and \(T(n-1)\), a disjoint union of cliques along anti-diagonals, and two disjoint unions of complete bipartite graphs \(K_{i,n-i}\). The triangular graphs are regular and integral, with explicitly determined spectra, and Weyl’s inequalities then give eigenvalue bounds for the full attack graph [2508.01088].

These abstractions are complementary. Hypergraphs encode feasibility and counting on toroidal and classical boards; inside-out polytopes control exact quasipolynomiality for fixed \(q\); queenons govern the classical asymptotic constant; and attack graphs expose spectral structure on the square-board geometry.

## 6. Variants, extensions, and asymptotic regimes

The peaceable queens problem replaces mutual non-attack by bipartite non-attack: maximize \(a(n)\) such that one can place \(a(n)\) white queens and \(a(n)\) black queens on an \(n\times n\) board with no opposite-color capture. For the regular board, \(a(n)\le 0.1716\,n^2\) for all sufficiently large \(n\), improving the previous \(0.25\,n^2\) bound. On the torus, parity causes a sharp odd–even split:
\[
t(n)\le 0.1402\,n^2 \text{ for all even } n,\qquad
t(n)\le 0.125\,n^2 \text{ for all odd } n,
\]
with asymptotic lower bounds \(0.1339\,n^2\) for even \(n\) and \(0.0833\,n^2\) for odd \(n\) [2406.06974].

Higher-dimensional random-placement models replace exact non-attack by the expected proportion of safe squares. For \(n\) random queens on an \(n\times n\) board, that proportion converges to
\[
\frac{2}{e^4}.
\]
The same framework defines line-queens and hyper-queens on \(k\)-dimensional boards, with rook-like contributions \(e^{-k}\) and additional bishop-like factors; in dimension \(3\), the line-queen safe-square proportion converges to
\[
\frac{-1 + 9e^2 - 2e^3}{3 e^9}
\]
[2409.04423].

Infinite-board greedy placement leads to another asymptotic geometry. On the doubly infinite board \(\mathbb{Z}\times\mathbb{Z}\) numbered along a square spiral, the greedy non-attacking queens are described by the Tribonacci word; the placements lie on four lines of slopes \(\pm \psi\) and \(\pm 1/\psi\), where \(\psi\) is the Tribonacci constant. On the single-quadrant board \(\mathbb{N}\times\mathbb{N}\) numbered along antidiagonals, rows and columns of the associated Sprague–Grundy table are permutations of \(\mathbb{N}\), and the queen positions are conjectured to lie on two lines of slopes \(\phi\) and \(1/\phi\) [1907.09120].

A fixed-\(q\) coverage variant asks, not for non-attack, but for the maximum number of covered squares. For each fixed \(q\), there is a non-attacking threshold beyond which all optimal configurations are pairwise non-attacking, and a stabilizing threshold beyond which the set of optimal configurations becomes constant. Using the resulting loss-function analysis, all optimal large-board configurations were determined for \(2\le q\le 9\) [2508.02545].

Taken together, these variants show that queens problems are not a single counting puzzle but a broad research domain. Their shared attack geometry supports arithmetic existence theorems, entropy maximization, quasipolynomial counting, rainbow matching methods, spectral decomposition, probabilistic asymptotics, and a growing catalogue of board-dependent threshold phenomena.

Source: https://www.emergentmind.com/topics/queens