zvold's blog

Hexagonal De Bruijn Torus

Here's a fun problem: take a hexagonal grid on a torus and put 0 or 1 into every hexagon, so that every permutation of 7-hexagon neighborhood occurs exactly once.

To clarify, rotations by multiples of 60⁰ are considered different. For example, both of these configurations should be present (individual hexagons are "vertical", like ⬢ ):

 1 0     0 0
0 0 0   1 0 0
 0 0     0 0

This is a known problem for the orthogonal grid: De Bruijn Torus, but a quick search yields no relevant results for hexagonal grids.

Is this even possible with hexagons? Turns out, it is!

I found a 32×4 torus relatively quickly, using backtracking:

0 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 1 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 1 1 1 0

Finding a 16×8 proved a bit harder, but then I shared my woes with a colleague. Next day, he found this 8×16:

0 0 1 1 1 1 1 0 0 1 1 1 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 1 1 1 1 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0

And, here's a 16×8 torus:

0 0 1 1 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 0 1 0 1 1

For the orthogonal grid, De Bruijn toruses can be assembled directly (see [1] and [2]). For the hexagonal grid, I don't know if there's a construction method better than backtracking.

Update (2024-05-08): Twisted Hexagonal De Bruijn Torus.


[1] Cock, J.C., 1988. Toroidal tilings from de Bruijn-Good cyclic sequences. Discrete mathematics70(2), pp.209-210. (link)
[2] Iványi, A., 1988. Construction of infinite de Bruijn arrays. Discrete applied mathematics22(3), pp.289-293. (link)