What is a snake in the box?
Take an n-dimensional cube and walk along its edges from corner to corner. The rule: you may never step next to a corner you have already visited, except the one you just came from. The longest such walk is called a snake.
The question goes back to W. H. Kautz in 1958, who needed it for error-detecting codes. The answer is known exactly only up to eight dimensions. Above that, every number is a record waiting to be beaten.
How this one was found
The previous record, Tom Taylor's 2938, is built recursively from snakes in lower dimensions, so it splits into pieces that each fill a 9- or 10-dimensional subcube. Holding the rest of the snake fixed, I cleared one piece at a time and rebuilt it with a GPU simulated-annealing search, keeping it whenever it came back longer. Three rebuilds took it from 2938 to 2944.
An exact constraint-programming search over a 50 to 60 edge window of one of those snakes then found a reroute two edges longer: 2946.
The record in thirteen dimensions
Bars are drawn to scale from 2650 edges.
The snake itself
Start at the corner 0000000000000. Each character below names the coordinate to flip next, counting from 0, with a, b and c standing for 10, 11 and 12.
Verify any snake
Paste a transition sequence and this page checks it in your browser: every corner distinct, and no two corners adjacent unless they are consecutive on the path. Nothing is sent anywhere.
Prefer the command line? verify.py does the same with only the Python standard library.
Citing
W. Toner, A snake of length 2946 in the 13-dimensional hypercube, Zenodo (2026). doi:10.5281/zenodo.23299075
The earlier 2944 is archived at doi:10.5281/zenodo.23297780. The full table of records in every dimension is kept by Tom Ace at minortriad.com/snake.