I’ve always loved the classical N-Queen puzzle. The goal is to place eight chess queens on an 8×8 chessboard so that no two queens attack each other.
Here’s one solution (92 in total):
Some time ago, a clever friend asked me if the number of solutions would be greater or lower if the goal was to place 7 queens instead of 8.
– «Greater, of course» – I replied.
– «And if you had to place 6?»
Then I realized that the number of possible solutions would peak at some point and then it would decrease until it hits 64 (the number of squares = the number of solutions if the goal was to place only one queen).
The highest number of solutions occurs when the goal is to place 5 queens.
Here’s the source code on GitHub.