Calculators
Two Queens Calculator
Count attacking and non-attacking placements of two queens on a rectangular chessboard with exact browser-only arithmetic.
Count ways to place two indistinguishable queens on distinct squares so neither attacks the other. Enter positive board dimensions of up to 100 digits. No other pieces or blocked squares are included. Results stay in your browser.
How to count non-attacking queen placements
On an r-row by c-column board, N = rc squares give N(N − 1)/2 unordered pairs of distinct squares. Queens attack along rows, columns and diagonals. Straight-line attacks contribute rc(r + c − 2)/2 pairs. For diagonal attacks, let k = min(r, c) − 1. Each diagonal offset d contributes 2(r − d)(c − d) pairs, so their sum is D = 2[krc − (r + c)k(k + 1)/2 + k(k + 1)(2k + 1)/6]. The straight and diagonal sets do not overlap for distinct squares. Subtract their sum from all pairs for the non-attacking count. An 8 × 8 board has 2016 total pairs, 728 attacking pairs and 1288 non-attacking pairs. A 2 × 3 board has 15 total pairs, 13 attacking pairs and 2 non-attacking pairs. A one-row or one-column board has no non-attacking pairs; a single square has no placements. The queens are indistinguishable: swapping them does not create a new placement. Double the counts for two labeled queens. This counts exactly two queens on a complete empty board, not solutions to the n-queens problem. There are no blocked squares, other pieces or wrapping edges. Enter positive whole numbers with up to 100 decimal digits per dimension. Leading zeros and surrounding whitespace are accepted; signs, decimals, separators and exponents are rejected. Closed formulas and BigInt arithmetic preserve every digit locally without visiting board squares.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
How many non-attacking queen pairs fit on an 8 × 8 board?
There are 1288 unordered non-attacking pairs: 2016 total pairs minus 728 attacking pairs.
How are attacking queen pairs counted?
Add row and column attacks rc(r + c − 2)/2 to diagonal attacks, the sum of 2(r − d)(c − d) for offsets d from 1 through min(r, c) − 1. These sets are disjoint.
Are the queens distinguishable?
No. Swapping the queens counts as the same placement. Double each count for two labeled queens.
What happens on a narrow board?
On a one-row or one-column board every pair attacks. A 2 × 3 board has two non-attacking pairs. A single square has no placements.
Does this solve the n-queens problem?
No. This counts placements of exactly two queens on an empty rectangular board. The n-queens problem places n queens with no shared row, column or diagonal.