# The Instant Insanity Problem

Years ago, a puzzle arose by the name of **Instant Insanity** by which you would take $4$ cubes of varying colours (e.g. red, orange, yellow, and green) with each cube having different colours on it, and try to stack them up as a rectangular prism. To solve the puzzle, you'd have to make it so that each rectangular face of the prism contained all four of the colours. The colours of the ends of the rectangular prism did not matter. For example:

The image above only shows two of the four rectangular faces of the rectangular prism, but each rectangular contains all of the colours. If the other two rectangular faces that are hidden also have one of each colour, then this would be a solution to the Instant Insanity problem. Notice that the colours of the ends don't matter. Now let's look at an arrangement of the cubes that is not a solution:

This is clearly not a solution to the Instant Insanity problem because one of the rectangles of the rectangular prism is missing red and has two oranges.

Now it might seem like finding a solution with four cubes is rather easy. The thing is, there are thousands of possibilities, so trial and error is not an effective approach.

## Solution to the Instant Insanity Problem

Imagine we take the four cubes and disassemble them in the following manner:

For example, here is a set of four coloured cubes (red, yellow, green, and blue) with a solution:

Now what we are going to want to do is create a graph representing each cube. We will have the colours be vertices of the graph, and edges be opposite faces of the cube. Front/back, left/right, and top/bottom are considered opposite faces of the cube. From the example above, we obtain the following graphs of the four cubes:

Now we're going to layer the graphs of the four cubes on top of each other, or superimpose them to make one large graph. We will label the edges of this superimposed graph with numbers corresponding to the cube they came from. The superimposed graph in our example is as follows:

Now we will be able to find a solution if we can find two subgraphs. Both of these subgraphs must have three specific properties:

**1.**Each of the subgraphs must contain exactly one edge from each cube. That is, a subgraph cannot contain two edges from one cube.

**2.**There cannot be any shared edges between the two subgraphs.

**3.**Each vertex of these subgraphs must be incident with exactly two edges.

For our example, we can obtain the following subgraphs:

Note that if two subgraphs with these properties cannot be formed, then there does not exist a solution to the set of cubes. If more than two subgraphs can be formed with these properties, then there is more than one solution to the set of cubes.

Now we're going to use these two subgraphs in order to tell us the orientation of the cubes. The first subgraph will tell us the colours of the faces of the cubes in the front/back positions, while the second subgraph will tell us the colours of the faces of the cubes in the left/right positions of the rectangular prism. Notice that the other edges of the cubes do not matter since they are either hidden or irrelevant to the problem, so we will not colour them in the example. Hence we obtain the following solution:

Notice that all four faces of the rectangular prism contain each colour once. Hence we have found a solution. Verify that the colours on the cubes exist by taking the figure from earlier and constructing it into $4$ cubes, then orient them from the information given in the two subgraphs we found.

## Creating Instant Insanity Cubes

You can easily create your own set of Instant Insanity cubes by working in the reverse process. First create two subgraphs with the three properties mention earlier, and super impose them. Then use any other colours for the rest of the faces of the cubes. Separate the graph into the $4$ graphs representing cubes $1$, $2$, $3$, and $4$. Each of these graphs will tell you the colours of opposite faces of the cube. You can then construct the cubes and verify the solution by orienting the cubes in accordance to the two subgraphs you started with.