I'm writing a program to help me solve a twisty puzzle. In this case it's the face-turning octahedron. I'm representing the puzzle as a group with face twists as generators. The facelets are in a list and the generators permute the list. So I need to compute the generators. I could compute them by hand and hard-code them (as ksolve requires) but I'd rather write code that exploits symmetries.
My approach so far
Per face, there are three corner facelets $c_i$, three edge facelets $e_i$, and three "landlocked" facelets $l_i$. I represent all 72 facelets in an array, each group of 9 in this order: $(c_0, c_1, c_2, e_0, e_1, e_2, l_0, l_1, l_2)$. Then I can simulate their rotation with the permutation $(1 2 0)(4 5 3)(7 8 6)$ on the appropriate segment of the array.
I also need to identify the facelets adjacent to the turning face -- the portions of adjacent faces that also move during the twist. How do I avoid hard-coding these? I can choose a row of 5 facelets along an edge such as $(c_0, l_0, e_0, l_1, c_1)$. Their indices are $(0, 6, 3, 7, 1)$. I use the rotation permutation above as a substitution rule to get the indices of facelets along a different edge of the same face. So then I need to hard-code the orientation of each face relative to the others.
I want a better way
This is still an awful lot of hard-coding considering how few choices there really are. It should be enough to specify only the adjacencies, the subdivision of a face, and for each neighbor of a face, the portion of the face attached to that neighbor, but I'm just not seeing how to get from here to there. Does anyone have useful insights?