Calculators

Two Kings Calculator

Count attacking and non-attacking placements of two kings on a rectangular chessboard with exact browser-only arithmetic.

Count ways to place two indistinguishable kings 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.

Enter the board dimensions.

How to count non-attacking king placements

On an r-row by c-column board, N = rc squares give N(N − 1)/2 unordered pairs of distinct squares. Kings attack adjacent squares horizontally, vertically and diagonally. Horizontal pairs contribute r(c − 1), vertical pairs contribute c(r − 1), and diagonal pairs contribute 2(r − 1)(c − 1). These sets are disjoint, so attacking pairs A = r(c − 1) + c(r − 1) + 2(r − 1)(c − 1). Non-attacking pairs equal N(N − 1)/2 − A. An 8 × 8 board has 2016 total pairs, 210 attacking pairs and 1806 non-attacking pairs. A 2 × 3 board has 15 total pairs, 11 attacking pairs and 4 non-attacking pairs. On a one-row board only neighboring squares attack; a single square has no placements. The kings are indistinguishable; swapping them does not create a new placement. For labeled kings, double the counts. This is a geometric count on a complete empty board without blocked squares or wrapping edges, not a count of complete legal chess positions. Enter positive integers 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 without visiting board squares. All processing stays in your browser.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

How many non-attacking king pairs fit on an 8 × 8 board?

There are 1806 unordered non-attacking pairs: 2016 total pairs minus 210 attacking pairs.

How are attacking king pairs counted?

Add horizontal, vertical and diagonal neighboring pairs: r(c − 1) + c(r − 1) + 2(r − 1)(c − 1). Each unordered pair is counted once.

Are the kings distinguishable?

No. Swapping the kings counts as the same placement. For two labeled kings, double each count.

What happens on a one-row board?

Only adjacent squares attack. A 1 × 3 board has three total pairs, two attacking pairs and one non-attacking pair. A single square has no placements.

Does this count legal chess positions?

No. This counts geometric placements of exactly two kings on an empty rectangular board. Full chess positions require other pieces and additional rules.