After trying and failing for about 10 minutes to solve the puzzle, I had a great idea, why not waste a couple of hours writing a program to solve it for me? And then a couple of hours turned into a couple more hours, but I got there in the end!
The aim is to wrap the snake into a 3x3x3 cube. Here is what the snake puzzle looks like when it is unwrapped.
How does the Program work?
There are two main approaches to solving the puzzle programmatically, you could either systematically enumerate all permutations of the snake, or randomly try different permutations until you find one that works.
I went with the second option. which seemed like it would probably be computationally slower, but easier to program.
I decided to write the code in Python, it works by randomly twisting the snake one joint at a time, and restarting everytime the snake either crosses itself or goes outside a 3x3x3 grid.
The code runs 100,000 simulations in approximately 20 seconds on my laptop, which turns out to be just about fast enough to get an answer when you leave the program to run for a couple of hours.
The program eventually gave me the following layout as a solution:
[[1, 16, 23], [18, 17, 22], [19, 20, 21]]
[[2, 15, 24], [5, 6, 7], [10, 9, 8]]
[[3, 14, 25], [4, 13, 26], [11, 12, 27]]
The easiest way to think about the solution the program gives is to think of the three blocks of three digits on the left as the bottom layer, the second block of three digits as the second layer, and then the third block of three as the third layer. So the 4th block is directly abov the third block.
Here is the completed puzzle: