The parity trick tests a counting constraint modulo two rather than computing each exact count. In the N queens oracle, odd column parity identifies the required one-queen columns. section 8.2.1
Use the trick when the surrounding constraints make parity sufficient:
- Assume every row already contains exactly one queen, then check each column for odd parity; any invalid placement has an empty column with even parity. section 8.2.1
- Skip one column because an invalid column distribution necessarily leaves enough even-parity empty columns to detect the violation. section 8.2.1
- Do not substitute parity for diagonal counts: zero or one queen on a diagonal may still be valid. section 8.2.1
N queens column check
For each column, compute the XOR of its queen-presence bits. Accept the column when the result is one; an even result identifies an empty column and marks the placement invalid. section 8.2.1
Figure 8.5 Check that each column has exactly one queen, knowing that each row has exactly one queen. We can count the parity of the number of queens in each column and check that it’s odd. Any placement for which this constraint is not satisfied will have at least one empty column with even parity.
A circuit diagram shows how odd column parity replaces exact counting when every row contains one queen. section 8.2.1
