There Are Magic Hexagons of Every Order
The Existence of Magic Hexagons Across All Orders
Originally published on gukov.dev | August 2, 2026
What makes the number 19 so distinctive?
This question surfaced during a recent gathering of YSDA alumni celebrating the school's 19th anniversary. One participant noted that 19 is the exact number of cells found in the only non-trivial normal magic hexagon.
A Note on AI-Assisted Mathematics We frequently hear reports of AI solving ancient conjectures through "miracles," often with very little transparency regarding the methodology. This account is intended to provide a window into the actual process of making such a mathematical breakthrough.
Magic Squares vs. Magic Hexagons
Most people are familiar with magic squares. These are grids where every row, column, and the two primary diagonals sum to a specific value called the magic constant.
To avoid the trivial boring solution of filling every cell with the same digit, we typically define a normal magic square as one containing consecutive integers from to . These structures have been studied for thousands of years, and we now possess reliable algorithms to build them for any order .
Magic hexagons are more elusive. In these, cells form lines in three distinct directions, and every single line must sum to the same constant.
Comparison of Magic Structures
| Feature | Magic Square | Magic Hexagon |
|---|---|---|
| Geometry | Quadrilateral Grid | Hexagonal Grid |
| Line Directions | 2 (Rows/Cols) + Diagonals | 3 |
| Normal Range | to | to |
| Availability | Every order | Only order and |
The Mathematical Hurdle
For a hexagon of order , there are lines in each of the three directions. For the hexagon to be "magic," the total sum of all numbers in the grid must be evenly divisible by .
For any order , the sum of consecutive integers from to fails this divisibility requirement.
Exploring "Abnormal" Magic Hexagons
To find more solutions, we can relax the rules. In an abnormal magic hexagon, we maintain the requirement for consecutive numbers, but we must start at 1 do not require the sequence to start at 1.
This slight change opens the door to new possibilities. However, unlike squares, there is no known deterministic formula for these. Researchers have had to rely on searching through an astronomical number of permutations.
- Current Status (as of July 2026):
- Order (Trivial)
- Order (Normal)
- Order (Largest known, discovered by Klaus Meffert in 2024)
Chapter 1: Human-Driven Observations
There is a fundamental conflict here: the numbers must be consecutive, yet the line sums must be identical despite the lines having different lengths. Since previous researchers had already optimized their search algorithms, I decided that the key was not to search faster, but to search a smaller space.
Observation A: The Power of Antisymmetry
I began by restricting the numbers to a symmetric range: . In this scenario, if the lines are magic, the sum of every line must be exactly zero.
By placing at the center and ensuring that any two cells opposite each other (via a 180-degree rotation) contain opposite values, the center lines automatically sum to zero. This follows the "drunkard's principle"—a plausible hunch that symmetry might simplify the problem.
Observation B: The 6-Point Ring
I discovered that any zero-sum hexagon can be constructed using a specific local pattern. If you take six cells surrounding an interior point and apply an alternating sequence:
[-1, +1, -1, +1, -1, +1]
...and leave the center cell alone, the line sums remain unchanged. This is because any line passing through this ring will either miss it entirely or hit exactly one and one .
These rings act as a basis for all zero-sum hexagons. This leads to two ways of viewing an order- zero-sum hexagon:
- Visible Values: The actual numbers in the cells.
- Potential Field: An order- grid that tracks how many of these local rings are applied at each point.
While the potential field guarantees that line sums are zero, it does not guarantee that the resulting numbers are distinct or consecutive. However, it allows us to search only within the space of zero-sum configurations.
Chapter 2: AI-Driven Discovery
During this period, I was assisting with the pre-solving of challenges for the Midnight Code Cup 2026—a competition where the use of Large Language Models (LLMs) is not just allowed, but encouraged...