Rubik' s Cube

Author

Eric W. Weisstein
April 15, 2024

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Puzzles/RubiksCube.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/RubiksCube.html.

©2024 Wolfram Research, Inc. except for portions noted otherwise

Graphic

NormalDirection[v_]:=Normalize[Cross[v[[2]]-v[[1]],v[[-1]]-v[[1]]]]

CuboidPolygons[xyz_]:=Normal[CanonicalizePolyhedron[Cuboid[xyz]]]/.Polyhedron[v_]:>Thread[Polygon[v]]

g=With[{
h=1.1,
colors=Sequence@@Flatten[
Transpose[{
With[{i=N@IdentityMatrix[3]},Join[i,-i]],
{Red,White,Blue,Yellow,Orange,Green}
}],1]
},
Graphics3D[
Table[
CuboidPolygons[h{i,j,k}],{i,0,2},{j,0,2},{k,0,2}]/.Polygon[x_]:>{
If[Union[x[[All,Position[Abs[NormalDirection[x]],1.][[1,1]]]]]≠{0}≠{2h+1},
Nothing,
Glow[Switch[NormalDirection[x],colors]]
],
Polygon[x]},
Boxed->False,Lighting->None
]]

Multiway graph

https://writings.stephenwolfram.com/2022/06/games-and-puzzles-as-multicomputational-systems/#groups-and-%28simplified%29-rubik%E2%80%99s-cubes

g1=({{"[◼]", "NestWhileGraph" }})[({{"[◼]", "IterateCubeTurn" }}),{Range[8]},UnsameQ@@#&,2,1,
DirectedEdges->False,
EdgeStyle->Gray,VertexStyle->Gray,
VertexShapeFunction->(Inset[({{"[◼]", "Cubedraw3D" }})[1,{,,,,,,,}[[#2]]],#1,Center,#3]&),
VertexSize->1.5,
VertexCoordinates-> MapIndexed[
#1->ReIm[Exp[I Pi/6(#2[[1]]-1) ]]&,
({{"[◼]", "IterateCubeTurn" }})@Range[8]],
GraphLayout->"SpringElectricalEmbedding",
PerformanceGoal->"Quality"]

g2=({{"[◼]", "NestWhileGraph" }})[({{"[◼]", "IterateCubeTurn" }}),{Range[8]},UnsameQ@@#&,2,2,
DirectedEdges->False,EdgeStyle->Gray,VertexStyle->Gray,
VertexShapeFunction->(Inset[({{"[◼]", "Cubedraw3D" }})[1,{,,,,,,,}[[#2]]],#1,Center,#3]&),
VertexSize->3,
GraphLayout->"SpringElectricalEmbedding",
PerformanceGoal->"Quality"]

GraphicsRow[{g1,g2}]