Chapter 16 The Tantalizing Four Cubes 289 16 The Tantalizing Four Cubes Author: William C. Arlinghaus, Department of Mathematics and Computer Science, Lawrence Technological University. Prerequisites: The prerequisites for this chapter are the basics of counting and graphs. See, for example, Sections 4.1, 7.1, and 7.2 of Discrete Mathematics and Its Applications, Second Edition, by Kenneth H. Rosen. Introduction The game of the four colored cubes consists of four cubes, each of whose sides is colored with one of four colors. The object of the game is to place the cubes next to each other in such a way that each of the long sides of the rectangular solid obtained has all four colors appearing on it. The game has been in existence since at least the 1940s, when it was sold commercially under the name "Tantalizer", and more recently as the popular puzzle "Instant Insanity". At the end of this chapter there is a template for a single cube. Readers may wish to copy it to make worksheets for themselves to follow the accompanying text — one sheet for each of the four cubes of the game. The Game: Problem and Solution I ..i simplicity, we will exhibit each cube unfolded in the fashion of Figure 1. I litis, wc want to arrange the cubes so that each of the four colors appears on ...It of the top, front, bottom, and back sides. The colors appearing on the left up I right are not relevant to the solution. 1 5 2 6 3 4 Figure 1. 1. Cube top. 2. Cube front. 3. Cube bottom. 4. Cube back. 5. Left side of cube. 6. Right side of cube. For example, if the four colors are red (R), white (W), blue (B), and (i,rcen (G), four cubes arranged as in Figure 2 would provide a solution to I he puzzle. Figure 3 shows the four cubes next to each other, viewed from the front, top, back, and bottom. R B R Q W Q W B Q R Q B G B B R R W B B W Q B R Figure 2. A solution to the puzzle. R Q B W G B W R R W Q B W G R B Figure 3. Upper left shows front view; upper right shows top view; lower left shows back view; lower right shows bottom view. It should be fairly clear that the difficulty of finding a solution depends v.reatly on the color pattern on each cube. One extreme case would be to have each cube colored a single different solid color (one each of red, white, blue, ^reen). In this case, it wouldn't matter how the cubes were rotated; every arrangement would be a solution. On the other hand, if all four cubes were colored solid red, no solution would be possible. 288 :".H) Applic.itionr, ol /'/•.< mtu M.ithtinui Our goal will be to use graph theory to Nimphl) tin- nciitcIi lor a solution in some general situation and then to us<...... methods to lind solutions in particular cases. But before we do this, it might help us to see how many different ways four cubes can be arranged. This may help us to realize why wo need some method of simplifying the problem. Example 1 Find the number of ways to arrange four cubes. Solution: The first fact to note is that there are essentially only three ways to arrange the first cube; that is, choosing the pair of faces which are on the left and right specifies the cube. For once these faces are chosen, the remaining faces may be rotated (with left and right fixed) so that any of them becomes the front. Even reversing left and right makes no difference, since rotating the cube to reverse left and right just reverses front and back, so that the four faces of interest appear in reverse order. R G Q B W Ft W R B B G Q Q R W B R B B Q R B B W Figure 4. Cubes of Figure 2 with left and right faces reversed. For example, Figure 4 exhibits the same cubes as Figure 2, but with left and right faces reversed. Once the first cube is positioned, however, the second cube may be positioned with respect to it in 24 ways. For the left-right pair may be chosen in 3 ways, either one of the pair may be the left face, and then the cube may be rotated to make any of the four remaining faces the front face. Similarly, each of the third and fourth cubes may be positioned in any of 24 different ways. Thus, the total number of positionings of the four cubes is 3-24-24-24 = 41,472. □ So, picking an arrangement which is a solution could be quite difficult. But graph theory can be used to make finding a solution easier, by providing an analysis of what a solution looks like. Given a set of four cubes with faces colored red, white, blue, and green, define a graph with four vertices labeled R, W, B, G as follows. If cube i has a pair of opposite faces with colors x and y, draw an edge with label i between x and y. Example 2 Use a graph to solve the puzzle for the cubes of Figure 5. ii R '' 1 R W ii 0 w w w w W Q W B B W Q R B G G R Figure 5. From left to right: cubes 1, 2, 3, 4. Solution: The graph of Figure 6 is the graph associated with the cubes of I [gure 5. Note that both loops and multiple edges are allowed in this labeled «raph. Figure 6. Graph associated with cubes of Figure 5. Now suppose that there is a solution of the puzzle with the cubes of Figure 5. Since the set of top and bottom faces must each have all four colors represented, the graph can be used to trace the colors on both faces simultaneously. Consider, for instance, the subgraph of Figure 6 shown in Figure 7. w Figure 7. Subgraph for top and bottom faces. This subgraph can be used to place the top and bottom faces. Since cube 1 has a pair of opposite faces labeled R-W, place cube 1 with red as the top face and white as the bottom face. Now cube 2 has a W-G pair, so place cube 2 Applications ol Discrete Mathematics with white as the top face and green as the bottom face. ( \>ntiiiue as the graph indicates, placing the top and bottom faces of cubes 3 and 4. At this point, the cubes appear as in Figure 8. R W W G G B B R Figure 8. Top and bottom faces. The key facts about the subgraph of Figure 7 that made this work were that there were four edges, one with each of the labels 1,2,3,4, and that each vertex had degree 2, so that each color was represented exactly twice. Now the task is to rotate the remaining four faces of each cube to obtain a solution. This will be possible if there is another subgraph of the graph of Figure 6, like that of Figure 7 but with four different edges, since each edge represents a different pair of opposite faces, and the ones of Figure 7 have already been used. Such a subgraph is illustrated in Figure 9. Figure 9. Subgraph for front and back faces. Using this subgraph to place the front and back faces of the cubes, the following solution to the problem of Figure 5 is obtained, in Figure 10. □ R R B R W Q W W R W G W G w W W B B B G Q G R R Figure 10. Solution for cubes of Figure 5. Note that, in this example, the positioning of the B-G pair in cube 1 was followed by the G-R pair in cube 4 since the label of the other edge incident with G was 4. Then the R-W pair of cube 2 was positioned, and finally the ( luipUn Iii Ihn l.mt.ili.-iiy I dim Cubin. I'iKI W It pair of cube 3 wmi |>ln< ed All of these positions were obtained by rotating the cubes with the lop mid bottom lixed. The colors on the left and right end up wherever this rotation lakes them, although of course what colors are there doesn't affect the solution. Tin; end result of this construction is the following theorem. Theorem 1 A set of colored cubes has a solution if and only if its corresponding labeled graph has two disjoint subgraphs, each of which has every vertex of degree two and every label appearing exactly once. ■ Several things should be noted about this theorem. First, if a loop is used in the subgraph, it contributes two to the degree of its vertex. For instance, subgraphs such as the ones of Figure 11 are acceptable subgraphs. 'Q, !0° Figure 11. A 4 y Acceptable subgraphs. Second, there may be many such subgraphs available. What is necessary is to find two subgraphs of the proper type with no edges in common. There may be no such pair of subgraphs; there may be a unique pair of acceptable subgraphs, as in the problem of Figure 5; or there may be many possible subgraphs, as shown in the following example. Example 3 Solve the problem of the cubes in Figure 12. R w G Q B G R R B W B G W R W B B W G R R W G G Figure 12. From left to right: cubes 1, 2, 3, 4. Solution: The graph for these cubes is shown in Figure 13. There are six allowable subgraphs, shown in Figure 14. 294 Applications ot Discmlo Muthwimllim i lutfitoi W Ilm l.int.ih.-iini I Mil Culun. 1"J!> Figure 13. The underlying graph for Figure 12. wO W R G B 0 . Figure 14. Six acceptable subgraphs. Top row: left to right, A, B, C; bottom row: left to right, D, E, F. Although Figure 14 exhibits six subgraphs of the type required by Theorem 1, there are only three pairs with distinct edges. They are AB, BC, and DE. Note that F cannot be paired with any other acceptable subgraph, so it is not of use in any solution. The three different solutions are exhibited in Figure 15 (the first subgraph of each pair is used for top and bottom). □ Games are, of course, fun. How much fun they are depends on how successful the player is; knowledge is directly linked to success in games of skill. At a deeper level, games can help to train thought processes. Consider how this game might be like others. This is a combinatorial game; what is required is to position cubes in relation to each other according to some predetermined II ii W Q (1 w 11 J n 0 W B B W G R R 1 R W Q Q B R W W G B R G R G R W B W B w G G R Q B R W B R W G G B W R W R G w B R R W B G G G G R B W B Q W R Figure 15. First row: AB solution. Second row: BC solution. Third row: DE solution. color scheme. Is any other game like this? Yes, "Rubik's Magic Cube" is, but this puzzle is much more complicated, as a combinatorial problem (see [3]). Then again, why confine the problem to cubical shapes. Might one construct puzzles with rules similar to those for the four colored cubes for prisms with a polygonal base and top other than a square? Learning to think creatively about puzzles, when translated to thinking creatively about mathematics (and other subjects), can reap rewards far beyond what might be expected! Suggested Readings 1. R. Busacker and T. Saaty, Finite Graphs and Networks, McGraw-Hill, New York, 1965. 2. G. Chartrand, Graphs as Mathematical Models, PWS, Boston, 1977. 3. D. Singmaster, Notes on Rubik's Magic Cube, Enslow Publishers, Hillside, N. J., 1981. 4. J. Van Deventer, "Graph theory and 'Instant Insanity'", in The Many Facets of Graph Theory, G. Chartrand and S. Kapoor, eds., Springer-Verlag, Berlin, 1969. . i :"Jti Agitation!, ol l)i:.t into M.lthoillttth : Exercises 1. Solve the following puzzle. ||,)W should IV Ih-h..... I"' re,>hrn»od if a) (.hero arc It ' "l" • 1111(1 :1 COlOM! h) there arc I) cuI.ch tuul 4 colors; c) there are 5 cuhes and 5 colors. What kind of graphs would give solutions. W B Q R B Q R W W Q B R W Q R W B Q W R Q R B R 2. Solve the following puzzle. Q w W R G R G B W B W G R B R R R B G Q W B B W 3. Find another solution to the puzzle for the previous exercise. 4. Solve the puzzle whose underlying graph is shown in the following figure. Computer Projects 1 Write a program that takes as input the pattern of colors on a set of four Xd cube's and finds all solutions (if there are any). 5. Construct a puzzle in which each color appears on at least four faces, but for which there is no solution. ★6. Construct a puzzle in which each color appears on each cube, but for which there is no solution. ★7. Construct a puzzle in which each color appears exactly six times and on each cube, but for which there is no solution. *8. Construct a puzzle with exactly two solutions.