Simple command line tool for solving the n-queens problem for arbitrary-sized boards. This repository is a companion for an upcoming blog post (link to follow).
- Prebuilt binaries are available from the
Releases
page for GOOS=Linux, Windows, Darwin.
- Fetch the source code
go get github.com/adammitha/n-queens
cd
into the root directory of the repository- Install the binary into your gobin
go install .
n-queens <size of board>
E.g. for an 8 x 8 board:
>n-queens 8
> Q ▢ ▢ ▢ ▢ ▢ ▢ ▢
▢ ▢ ▢ ▢ Q ▢ ▢ ▢
▢ ▢ ▢ ▢ ▢ ▢ ▢ Q
▢ ▢ ▢ ▢ ▢ Q ▢ ▢
▢ ▢ Q ▢ ▢ ▢ ▢ ▢
▢ ▢ ▢ ▢ ▢ ▢ Q ▢
▢ Q ▢ ▢ ▢ ▢ ▢ ▢
▢ ▢ ▢ Q ▢ ▢ ▢ ▢