PLAY · TEST · UNDERSTAND
Magic Square Solver
Use the Magic Square Solver in Magic Square Archive to explore a normal three by three square from clues placed anywhere in the grid. This size supports backtracking: the search tries unused numbers, checks constraints, and retreats when a choice cannot work. For orders four through nine, the tool is limited to validation and deduction within a line containing exactly one blank.
Magic square solver
Use each integer from 1 to 9 once. Every row, column and both diagonals must sum to 15.
Enter any clues. Blank cells are unknown, not zero. Load example replaces the board with editable sample clues.
Order 3: real backtracking from your clues, with pruning and a 50000-node budget. Finds one solution, not all solutions; existing clues are preserved.
- Magic constant
- 15
What the three by three search solves
A normal three by three magic square uses each integer from one to nine exactly once. Every row, every column, and both main diagonals must total fifteen. A grid with equal row totals alone is not enough: a diagonal can still fail, or a number can be repeated.
Clues may occupy corners, edges, or the center; they do not need to form a completed row. Backtracking looks for a completion that preserves their positions while satisfying the normal square rules. Inconsistent clues have no valid completion. Finding a completion does not, by itself, establish that the clues determine a unique answer.
Use the line totals to understand a result
The normal magic sum is M = n(n² + 1)/2. For n = 3, this gives fifteen. One valid arrangement has rows 8, 1, 6; 3, 5, 7; and 4, 9, 2. Its columns and both diagonals also total fifteen.
If a row already contains eight and one, its missing value must be 15 − 8 − 1 = 6. That calculation fixes only that position. The same six must also fit its column and any main diagonal it lies on, without duplicating another entry.
What orders four through nine can do
For larger supported orders, use validation to examine entries against the normal square requirements. Their target sums follow the same formula: order four has thirty-four and order nine has three hundred sixty-nine. A completed square needs the correct number range, no repetitions, and every required line total.
A row, column, or main diagonal with exactly one blank permits a direct deduction: subtract its known entries from the target sum. Check that the result is an unused integer in the allowed range. This is local arithmetic, not a general backtracking search for larger squares.
When the available reasoning stops
Several blanks in one line cannot generally be resolved by subtraction alone. Higher order clues may therefore remain incomplete even when no immediate contradiction appears. For three by three puzzles, use backtracking to test completion; for orders four through nine, treat validation and single missing entry deductions as checks, not promises of a full solution.