Donald Knuth has posted results of an experiment “What a joy it is to learn [...] that my conjecture has a nice solution.”
https://www-cs-faculty.stanford.edu/~knuth/papers/claude-cycles.pdf
https://www-cs-faculty.stanford.edu/~knuth/papers/claude-cycles.pdf
In a toroidal cubic lattice with odd edge-length n, can the edges be three-colored into Hamiltonian cycles? Knuth: “I had solved the problem for m = 3, and asked for a generalization as part of the answer to an exercise in [3]. My friend Filip Stappers rose to the challenge, and empirically discovered solutions for 4 ≤ m ≤ 16.”
They had solutions. Could they extend to infinity? Did a “nice” solution exist? A point figured out early was that no trivial solution existed. Eventually, they tossed the problem to LLM Claude. It managed to come up with a solution for odd values.
ClaudeAllCycles[m_Integer?Positive,start_:{0,0,0}]:=Module[{perm,step,cyc,vstr},perm[v_]:=With[{i=v[[1]],j=v[[2]],s=Mod[Total[v],m]},Which[s==0,If[j==m-1,{0,1,2},{2,1,0}],s==m-1,If[i>0,{1,2,0},{2,1,0}],True,If[i==m-1,{2,0,1},{1,0,2}]]];step[c_][v_]:=Switch[perm[v][[c+1]],0,{Mod[v[[1]]+1,m],v[[2]],v[[3]]},1,{v[[1]],Mod[v[[2]]+1,m],v[[3]]},2,{v[[1]],v[[2]],Mod[v[[3]]+1,m]}];cyc[c_]:=Most@NestList[step[c],start,m^3];vstr[v_]:=StringJoin[IntegerString[#,16]&/@v];(vstr/@cyc[#])&/@Range[0,2]]
In[]:=
claude3=UndirectedEdge@@@#&/@(Partition[#,2,1,1]&/@ClaudeAllCycles[3,{0,1,2}]);vv3=StringJoin/@Tuples[ToString/@Range[0,2],{3}];
Here’s one representation of the solution.
ch3=Graphvv3,Flatten[claude3],
Out[]=
A different version, plotted on the vertices of the equivalent Hamming graph.
Graphvv3,Flatten[claude3],
Out[]=
The paths are not symmetric.
In[]:=
Graph[vv3,#,VertexCoordinates->Thread[vv3->GraphData[{"Hamming",{3,3}},"VertexCoordinates"]]]&/@claude3
Out[]=
,
,
Here’s a 3D version:
Graph3Dvv3,Flatten[claude3],
Out[]=
The nice solution works for odd values, so here’s the solution for 5:
In[]:=
claude5=UndirectedEdge@@@#&/@(Partition[#,2,1,1]&/@ClaudeAllCycles[5,{0,1,2}]);vv5=StringJoin/@Tuples[ToString/@Range[0,4],{3}];
Graphvv5,Flatten[claude5],
Out[]=
In 3D
In[]:=
Graph3D[vv5,#,VertexCoordinates->Thread[vv5->(Tuples[Range[0,4],{3}]+(Table[Mean[#^2],{3}]&/@Tuples[(Range[0,4])/2,{3}]))]]&/@claude5
Out[]=
,
,
The order 7 version
In[]:=
claude7=UndirectedEdge@@@#&/@(Partition[#,2,1,1]&/@ClaudeAllCycles[7,{0,1,2}]);vv7=StringJoin/@Tuples[ToString/@Range[0,6],{3}];
Graphvv7,Flatten[claude7],
Out[]=
One portion of the 3D solution.
A “nice” solution for the problem still hasn’t been found for even values, but a complicated solution was found by Ho Boon Suan.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Claude cycles -- How to split a 3D toroidal lattice
by Ed Pegg
Wolfram Community, STAFF PICKS, March 4, 2026
https://community.wolfram.com/groups/-/m/t/3649071
by Ed Pegg
Wolfram Community, STAFF PICKS, March 4, 2026
https://community.wolfram.com/groups/-/m/t/3649071