English

Counting $N$ Queens

Computation 2024-07-15 v1

Abstract

Gauss proposed the problem of how to enumerate the number of solutions for placing NN queens on an N×NN\times N chess board, so no two queens attack each other. The N-queen problem is a classic problem in combinatorics. We describe a variety of Monte Carlo (MC) methods for counting the number of solutions. In particular, we propose a quantile re-ordering based on the Lorenz curve of a sum that is related to counting the number of solutions. We show his approach leads to an efficient polynomial-time solution. Other MC methods include vertical likelihood Monte Carlo, importance sampling, slice sampling, simulated annealing, energy-level sampling, and nested-sampling. Sampling binary matrices that identify the locations of the queens on the board can be done with a Swendsen-Wang style algorithm. Our Monte Carlo approach counts the number of solutions in polynomial time.

Cite

@article{arxiv.2407.08830,
  title  = {Counting $N$ Queens},
  author = {Nick Polson and Vadim Sokolov},
  journal= {arXiv preprint arXiv:2407.08830},
  year   = {2024}
}
R2 v1 2026-06-28T17:37:55.174Z