TrialPay Engineering Challenge: The Snake Cube Puzzle

At TrialPay, our engineers love puzzles. When we aren’t busy solving interesting problems building a robust, feature-rich platform, we like to stay sharp by challenging one another with unique puzzles that allow us to think about our technical challenges in different ways.

If you’re up for the challenge below, you can submit your solution to

If you submit a good solution and send along a GitHub/StackOverflow/LinkedIn profile or resume, we will contact you for an interview.

Snake Cube
Recently, one of our engineers introduced us to the snake cube. A snake cube is a puzzle composed of a chain of cubelets, connected by an elastic band running through each cubelet. Each cubelets can rotate 360°about the elastic band, allowing various structures to be built depending upon the way in which the chain is initially constructed, with the ultimate goal of arranging the cubes in such a way to create a cube.

Consider the 27-cubelet snake, which assembles into a 3*3*3 cube, shown below.

This particular arrangement contains 17 groups of cubelets, composed of 8 groups of two cubelets and 9 groups of three cubelets. This arrangement can be expressed in a variety of ways, but for the purposes of this exercise, let ’0′ denote a pieces whose rotation does not change the orientation of the puzzle, or may be considered a “straight” piece, while ’1′ will denote pieces whose rotation changes the puzzle configuration, or “bend” the snake. Using that schema, the snake puzzle above could be described as


Your challenge is to write a program, in any language of your choosing, that takes the cube dimensions (X, Y, Z) and a binary string as input, and outputs ’1′ (without quotes) if it is possible to solve the puzzle, i.e. construct a proper X*Y*Z cube given the cubelet orientation, and ’0′ if the current arrangement cannot be solved.

snake_cube_solution(3, 3, 3, “001110110111010111101010100″) == 1

Bonus points are given for printing out the final x,y,z coordinates for each cubelet, in order, assuming that the first block of the cube always begins at (1,1,1) and the final cubelet always ends with (X,Y,Z).

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s