---
title: "A construction of optimal single-track Gray codes of length 2p"
authors:
  - "Minjia Shi"
  - "Xinguang Dai"
year: 2026
venue: "arXiv preprint (cs.IT; cross-listed math.CO)"
arxiv: "2611.36149"
doi: null
source: "https://arxiv.org/abs/2611.36149"
version_reviewed: "v1"
topics:
  - "gray-codes"
  - "necklaces"
  - "euler-circuits"
  - "rotary-encoders"
  - "combinatorics"
seed_rank: 2765
seed_batch: "curiosity-2026-12-01"
reviewed: "2026-11-30"
pool: "maths-foundations"
relevance_score: 7
cites:
  - title: "A construction of optimal single-track Gray codes of length 2p"
    url: "https://arxiv.org/abs/2611.36149"
    year: 2026
    arxiv: "2611.36149"
    doi: null
see: []
---

# A construction of optimal single-track Gray codes of length 2p

## One-sentence takeaway

For every odd prime p there is a binary single-track Gray code of length 2p reaching the maximum possible period 2^{2p} − 4. This settles the Schwartz–Etzion question from 1999 by ordering necklace representatives along an Euler circuit in a directed multigraph.

## Why it's lovely

A single-track Gray code is the combinatorics behind an absolute rotary encoder with one printed track and n read heads. Every column of the code is a cyclic shift of the first, so one ring of ink is enough, and only one bit changes per step, so a misread at a boundary costs at most one position. The question is how many positions n heads can resolve. The answer here is "all but four of the 2^{2p} words", and the construction reads like a puzzle solution. The 4p-element orbits of the complemented cycling register (shift and complement) cover every word except four. Treat the orbits as arcs of a multigraph. At each vertex the allowed one-bit transitions form a p-dimensional cube, and Fink's perfect-matching theorem on hypercubes glues the local circuits into one Euler circuit. The smallest case already shows it: p = 3 gives a length-6 code of period 60 = 2⁶ − 4 from five generating words (001000, 001001, 000001, 000101, 010101) with heads at 0, 5, 10, 15, 20, 25. For Anoptic and ano, this is a lovely instance of "make the whole sequence out of shifts of one stream", the same economy as SoA columns that are rotations of a single buffer. That bridge is mine, not the paper's.

## Key ideas

- **Bound and target.** Schwartz and Etzion showed that 2^n − 2n is the maximum period for n = 2^m. For n = 2p they conjectured that full-order self-dual necklaces of length 4p give period 2^{2p} − 4 (also posed as Problem 7.1 in Etzion's survey).
- **Orbit structure.** Under T (cyclic shift plus complement), the orbits of size 4p contain all binary words of length 2p except four (Etzion, Theorem 6).
- **Euler circuit.** Orbits become arcs. Permitted transitions at each nonzero vertex form a p-cube, and Fink's matching theorem joins the local matchings into a single Euler circuit. Choosing one representative per orbit along it gives successive words at Hamming distance 1.
- **Closing the loop.** An alignment choice at the zero vertex plus a coordinate relabelling makes the last representative adjacent to the T-shift of the first. Concatenating the 4p T-shifts then gives the code (period P = 4pr with r = (4^{p−1} − 1)/p).
- **Open.** The maximum period for length 2m with odd composite m is still unknown. The closing rotation needs an exponent coprime to m.

## Caveats

This is a v1 preprint, unrefereed. The authors declare they used ChatGPT for proofs and language editing and that they reviewed and verified all AI-assisted content. The problem was suggested by Etzion during a visit to Hefei. The practical encoder framing comes from the paper's introduction. The result is about existence and construction, not a hardware evaluation. I read the introduction, the proof outline, the p = 3 example and the closing remarks.

## Links

- arXiv abstract: https://arxiv.org/abs/2611.36149
- PDF: https://arxiv.org/pdf/2611.36149
