Problem 50629. Solve the snake puzzle
My son received this puzzle toy from grandma for his 7th birthday, but he's having a bit of trouble solving it. Can you help?
The toy is a "twisting snake" puzzle made of 27 blocks connected by hidden strings into sixteen segments, each either two or three blocks long. The snake's path must make a 90-degree turn at the end of each segment.
The object is to arrange the puzzle's blocks into a 3-by-3-by-3 cube.
These pictures show the puzzle's configuration when laid out two-dimensionally and its final state when solved.
Your code should return a 27x3 array containing the path traversed by the snake when the puzzle is solved. Each row corresponds to one position, with [1 1 1] representing the back left lower corner of the cube and [3 3 3] representing the front right upper corner. For example, if the path begins in the front left lower corner and the first segment proceeds to the right, the first three rows of the array would be [3 1 1; 3 2 1; 3 3 1].
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
Get the area codes from a list of phone numbers
1032 Solvers
-
341 Solvers
-
27 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
10244 Solvers
-
Snow Accumulation and Structural Risks To Residential Properties
108 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!