Last December, a young cousin of mine got a snake cube for Christmas. He showed it to me. Even though I have never seen that thing, I took a low pitched voice, hinted with a lot of self confidence that it was very easy to do/undo it. In the manipulation, I unfolded it and... was completely unable to fold it again into its original cube shape. I was a little bit ridiculous and later decided that at least there is a good way to turn this domestic defeat into a learning experience: I should solve this snake cube.. No ! All snake cubes !! Forever !!!

Nothing difficult, of course, but the problem still requires to be approached in an organized fashion.

### Introduction

A snake cube puzzle is a string of 27 cubes connected by an elastic that goes through each cube. The elastic goes either straight through the cube, from one face to the opposite, or turns inside the cube and goes from one face to an adjacent. The aim of the game is to fold it into a 3x3x3 cube, if possible. It is usually quite difficult to do it the first time, when a snake does not have many solutions.

Our objective here is to find all possible solution snake cubes (ignoring rotations and reflections), and sort them to try and make sense of how this population is distributed. To be more specific, any 2 snakes that are identical after a series of rotations and/or reflections are considered one solution.

A solution snake cube is an undirected Hamiltonian path in the 3x3x3 grid graph.

In order to explore the possibilities in an orderly and economical way, we first describe a method to travel inside the grid graph, starting from specific first few vertices all the way to Hamiltonian path. We try to avoid doing redundant searches. Indeed the cube has many symmetric axes, and many symmetric starting points. There are many possibilities to explore so this concern for optimisation is no luxury.

Once the search is complete, we sort the solution snake cube (the "paths") by letter sequence. A letter sequence is a string of 27 letters that define a snake cube puzzle.

- E for and end cube.
- S for a 'straight' cube; the elastic goes from one face to the opposite face.
- C for a 'corner' cube; the elastic goes from one face to an adjacent face.

Within all the paths for one sequence, we determine the "base" paths, ie those which cannot be deducted one from the other by a combination of rotations and/or reflections ("transformations"). This step requires a lot of calculations so all transformation are computed beforehand.

Finally we get all the base paths and can examine the results.