logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·31.10.26
← Back to news

There Are Magic Hexagons of Every Order

Original article
gukov.dev|148 points|21 comments|by gukoff|Aug 9, 2026

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 111 to n2n^2n2. These structures have been studied for thousands of years, and we now possess reliable algorithms to build them for any order n≥2n \ge 2n≥2.

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

FeatureMagic SquareMagic Hexagon
GeometryQuadrilateral GridHexagonal Grid
Line Directions2 (Rows/Cols) + Diagonals3
Normal Range111 to n2n^2n2111 to 3n2−3n+13n^2-3n+13n2−3n+1
AvailabilityEvery order n≥2n \ge 2n≥2Only order n=1n=1n=1 and n=3n=3n=3

A visualization of the order-3 magic hexagon

The Mathematical Hurdle

For a hexagon of order nnn, there are 2n−12n-12n−1 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 2n−12n-12n−1.

For any order n>3n > 3n>3, the sum of consecutive integers from 111 to 3n2−3n+13n^2-3n+13n2−3n+1 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 n=1n=1n=1 (Trivial)
    • Order n=3n=3n=3 (Normal)
    • Order n=9n=9n=9 (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: −K,…,K-K, \ldots, K−K,…,K. In this scenario, if the lines are magic, the sum of every line must be exactly zero.

By placing 000 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 +1+1+1 and one −1-1−1.

These rings act as a basis for all zero-sum hexagons. This leads to two ways of viewing an order-nnn zero-sum hexagon:

  1. Visible Values: The actual numbers in the cells.
  2. Potential Field: An order-(n−1)(n-1)(n−1) grid that tracks how many of these local rings are applied at each point.

Line Sums=0  ⟺  Represented by Potential Field\text{Line Sums} = 0 \iff \text{Represented by Potential Field}Line Sums=0⟺Represented by Potential Field

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...