Problem 51 · Hard

N-Queens

Place n queens on an n by n board so that no two attack each other, and list every complete placement. The visual places one queen per row, blocks columns and diagonals, and backtracks when a row has no safe square.

Open the interactive visualisation