What is N-Queens?
The N-Queens puzzle is a classic chess-based logic problem where you must place N queens on an N×N chessboard so that no two queens attack each other. Queens attack horizontally, vertically, and diagonally, making this a challenging constraint-satisfaction puzzle. This tool supports puzzles ranging from 4 to 12 queens, offering both puzzle-solving mode and solutions for learning how different configurations work.
How to Use
Select your desired board size (4 to 12 queens) and enter puzzle mode. Click on empty squares to place queens, and the board will highlight attacked positions in red to guide your placement. If you make a mistake, click a queen to remove it and try again. The tool provides real-time feedback, preventing you from placing queens in attacked squares. Once you successfully place all queens without conflicts, you've solved the puzzle. Use the solution mode to view correct configurations if you get stuck or want to verify your answer.
Use Cases
Teach students about algorithmic thinking and constraint satisfaction problems in computer science education. Practice logical reasoning and spatial visualization skills during breaks. Use as a brain-training exercise to improve problem-solving abilities. Study how backtracking algorithms work by examining different puzzle solutions and patterns.
Tips & Insights
Start with smaller board sizes (4-6 queens) to build intuition before attempting larger ones. The N-Queens problem becomes exponentially harder as board size increases, making it a legitimate computational challenge. Multiple valid solutions exist for most configurations—finding even one solution demonstrates strong logical thinking. Understanding this puzzle helps in learning about algorithm optimization and complexity theory.
Frequently Asked Questions
What is the N-Queens problem?
The N-Queens problem involves placing N queens on an N×N chessboard so no queen can attack another. Since queens move any number of squares vertically, horizontally, or diagonally, no two queens can share the same row, column, or diagonal. It's a classic problem in mathematics and computer science, often used to teach backtracking algorithms.
How many queens are supported?
This tool supports 4-queens (4×4) through 12-queens (12×12). The 4-queens puzzle is relatively simple with 2 solutions, the classic 8-queens problem has 92 solutions, and 12-queens has over 14,200 solutions with significantly higher difficulty. For beginners, we recommend starting with 4–6 queens.
How does the auto-solver work?
The solver uses the backtracking algorithm to find solutions. It places queens column by column from left to right, and when a conflict occurs, it backtracks to try another position. By repeating this process, a solution is guaranteed. When a solution is found, queens appear one by one in animation. The hint button reveals only the next correct square to place.
What is challenge mode?
It's a 3-minute time-attack mode. Solve as many N-queens puzzles as possible to earn points (4-queens = 10 points, 12-queens = 120 points). You can also earn streak bonuses for consecutive correct solutions. Each new puzzle uses a random N value.
Can I create custom board sizes beyond 12 queens?
Puzzle mode officially supports boards from 4 to 12 queens. Larger custom sizes may be available in challenge mode depending on your browser's processing power.
Is there a time limit to solve the N-Queens puzzle?
Puzzle mode has no time limit, allowing you to think through the solution at your own pace. Challenge mode may include time restrictions for competitive play.
Can I get hints or see partial solutions?
The auto-solver feature can reveal the solution step-by-step to guide you through the problem. Using hints typically doesn't prevent you from recording the completion, but some challenge levels may restrict their use.
How does the game validate my solution as correct?
Once you place all queens on the board, the game instantly checks that no two queens attack each other. It will highlight any conflicts and confirm successful completion.
How does difficulty change as the board size increases?
Complexity grows exponentially as you increase from 4 to 12 queens. Boards with 4-6 queens help you learn the constraints, while 10-12 queens present significantly challenging strategic problems.
Can I save or share my puzzle solutions?
Completed puzzles are saved to your browser's local storage for future review. Some versions support exporting solutions as images or diagrams for sharing with friends.