[Math] Numbering edges of a cube from 1 to 12 such that sum of edges on any face is equal

algorithmscombinatoricspuzzle

Assign one number from 1 to 12 to each edge of a cube (without repetition) such that the sum of the numbers assigned to the edges of any face of the cube is the same.

I tried a bunch of equations but I always ended with more variables than number of equations. So I figured this isn't really a simultaneous equations question.

I pondered if Permutations/Combinations would help. Couldn't figure out much there either.

The only solution I could think of was brute-force (a.k.a trial and error). Or to do it in a slightly manner I thought I could use a backtracking algorithm (http://en.wikipedia.org/wiki/Backtracking). Is that the best way or is my math really rusty?

Best Answer

I found this not hard to solve with a pen and a piece of paper towel, so I suspect that it's rather unconstrained and there are many solutions. Later on I may write a program to generate all possible solutions and count them, but for now here's what I did to find a single solution. (Addendum: I did eventually write the program; see the comment below.)

The first step, as already described in the comments, is to find out what the sum of the numbers on a face must be. Let $F$ be the sum of the four edges of a face. The total of all six faces is $6F$. But this counts each edge twice, and the sum of the 12 edges is $1+2+\cdots+12 = 78$, so $6F = 2\cdot 78$, and $$F=26.$$

(Consider a related problem: Arrange the numbers $1,\ldots,12$ in a $3\times 4$ array so that the numbers in each row have the same sum and the numbers in each column have the same sum. There are 4 columns, whose sums together add up to $1+2+\cdots+12 =78$, so for each to have the same sum, each one must sum to $\frac{78}4$. This is impossible, so we know right away that there is no solution.)

With $F=26$, it's natural to consider the numbers in pairs $1–12, 2–11, \ldots, 6–7$ where the pairs always add up to $13$. If we could arrange that each face had exactly two pairs, we would win. Also, we might imagine that the numbers are divided into small numbers $1\ldots 6$ and large numbers $7\ldots 12$. Maybe we can find a solution by matching small numbers with large numbers. To that end, let's arrange $1,12,2,11$ around the middle of the cube, like this:

cube with 1,12,2,11 around the middle

This drawing is too complicated and not compact enough. If we could find a compact representation of the cube that still shows the relationships between the edges and the faces. it would be quicker and simpler to investigate different arrangements of numbers. So suppose the edges of the cube are labeled like this:

cube with 12 letter labels on edges

From now on we'll write this cube like this:

$$\def\r#1{\color{maroon}{#1}}\begin{array}{cccccccc} & \r E && \r F && \r G && \r H\\\r A && \r B && \r C && \r D \\& \r I && \r J && \r K && \r L \\ \end{array}$$

Five of the six faces are easily visible in this display. Three of the middle faces are $AEBI, BFCJ, CGDK$. The fourth wraps around from the right end to the left: $DHAL$. The last two faces are the top and bottom and are $EFGH$ and $IJKL$, which are easy to see in the diagram.

Our assignment of $1,12,2,11$ from before is now:

$$\def\bl#1{\color{blue}{#1}} \begin{array}{cccccccc} & \r E && \r F && \r G && \r H\\\bl1 && \bl{12} && \bl2 && \bl{11} \\& \r I && \r J && \r K && \r L \\ \end{array}$$

The four side faces have so far been assigned edges that total 13, 14, 13, and 12 respectively. We have remaining the four small numbers $3,4,5,6$ and the four large numbers $7,8,9,10$. Since $E$ and $I$ must total 13, let's assign them $6$ and $7$ and see what happens next:

$$\begin{array}{cccccccc} & \bl6 && \r F && \r G && \r H\\1 && 12 && 2 && 11 \\& \bl7 && \r J && \r K && \r L \\ \end{array}$$

Now we need to assign $F$ and $J$, which must add to 12. We have left $3,4,5,8,9,10$. We could use $3,9$ or $4,8$. Let's try $3,9$. (Let's call this decision “$\star$”; it turns out to be wrong, so we'll come back to it later.) It doesn't really matter which one we put on top, since we can switch them later without affecting any of the totals except the top and bottom face. But since we put the small number $6$ on the top face before, let's put the large number $9$ on top this time, to try to keep the top and bottom faces balanced:

$$\begin{array}{cccccccc} & 6 && \bl9 && \r G && \r H\\1 && 12 && 2 && 11 \\& 7 && \bl3 && \r K && \r L \\ \end{array}$$

Now we want to assign $G$ and $K$. We have $G+2+K+11 = 26$, so $G+K= 13$, and the unused numbers are $4,5,8,10$. The only pair we can still use is $5,8$. So let's assign those:

$$\begin{array}{cccccccc} & 6 && 9 && \bl5 && \r H\\1 && 12 && 2 && 11 \\& 7 && 3 && \bl8 && \r L \\ \end{array}$$

Finally, the last two numbers are $4$ and $10$, which combine with the $11$ and $1$ in the $11,L,1,H$ face to make 26. Since we put the small number $5$ on top last time, let's put the large number $10$ on top this time:

$$\begin{array}{cccccccc} & 6 && 9 && 5 && \bl{10}\\1 && 12 && 2 && 11 \\& 7 && 3 && 8 && \bl4 \\ \end{array}$$

Now the four faces around the middle all add up to 26, but the top face is $6+9+5+10 = 30$ and the bottom face is $7+3+8+4 = 22$. Let's call this a “deficit” of 8, the amount by which the bottom face falls short of the amount of the top face. We want a deficit of 0.

We can change the deficit by swapping numbers between the top and bottom. The sides faces all add to 26 so we don't want to change them. But if we swap a top number $t$ with the corresponding bottom number $b$ on the same side face, the deficit will decrease by $t-b$, and the totals on all four side faces will remain as they were. The top-bottom pairs are $6–7, 9–3, 5–8, $ and $10–4$. These contribute $-1, +6, -3, $ and $+6$ to the deficit, respectively, for a total of $+8$. We can change the sign of each contribution from $+$ to $-$ or vice versa, and we want the total deficit to be 0. This is evidently impossible (to see this, just consider whether the 6es should have the same sign or opposite signs; neither works), so we are in a blind alley.

Backing up to the last choice we had, $\star$, we found that adding $3,9$ at that point failed. So let's add $4,8$ instead, obtaining:

$$\begin{array}{cccccccc} & 6 && \bl8 && \r G && \r H\\1 && 12 && 2 && 11 \\& 7 && \bl4 && \r K && \r L \\ \end{array}$$

Then $G+K= 13$ and we have only $3 ,5, 9, 10$, so we take $G,K =3,10$:

$$\begin{array}{cccccccc} & 6 && 8 && \bl3 && \r H\\1 && 12 && 2 && 11 \\& 7 && 4 && \bl{10} && \r L \\ \end{array}$$

and then $5,9$ go in last:

$$\begin{array}{cccccccc} & 6 && 8 && 3 && \bl5\\1 && 12 && 2 && 11 \\& 7 && 4 && 10 && \bl9 \\ \end{array}$$

This time the top totals $6+8+3+5= 22$ and the bottom $7+4+10+9 = 30$, so the bottom has a surplus of $8$. The top-bottom pairs contribute surpluses of $+1, -4, +7, +4$, respectively. We want to switch the signs on these so that they add up to 0. Clearly switching the $+4$ to $-4$ will work, so we swap the positions of $5$ and $9$:

$$\begin{array}{cccccccc} & 6 && 8 && 3 && \bl9\\1 && 12 && 2 && 11 \\& 7 && 4 && 10 && \bl5 \\ \end{array}$$

which is a solution:

solution as above

Related Question