This question on CGCC.SE fascinated me.

In particular @xnor's brilliant answer provided an elegant polynomial to provide the solution.

In summary, the question asks for a program that, for an isometrically viewed die, and given the values of the left and right visible faces, will provide the value of the top visible face.

The polynomial found (I think by brute force) by xnor is:

$$t=3(l^3r-lr^3) \bmod 7$$

There is no explanation as to why this works, other than brute-force proof by plugging in all possible values (there are only 24 possibilities for regular 6-sided dice).

I'd love to understand why this works. Can anyone provide a mathematical derivation of this polynomial, other than "it just works"?


1 Answer 1


Here's a derivation. It's less clean than I'd like, but it does the job.

Let a triple $(a,b,c)$ denote three visible faces of the die. We'll work modulo 7 and treat the die faces as $\{-3,-2,-1,+1,+2,+3\}$, noting that opposite faces adding to $0$. So $(a,b,c)$ are a permutation of $(\pm 1, \pm2, \pm3)$.

We will express a relationship between three $\pm1$-value functions that describe the triple.

  • The handedness $h(a,b,c)$ is $+1$ for right-handed triples on the die and $-1$ for left-handed triples.

  • The sign $s(a,b,c)$ is the number of minus signs among $(a,b,c)$ from $\{\pm 1, \pm2, \pm3\}$.

  • The chirality $f(a,b,c)$ is the cyclic order of $(1,2,3)$ in $(a,b,c)$, ignoring sign. The cyclic order $(1,2,3)$ gives $+1$ and $(1,3,2)$ gives $-1$.

Claim: For any triple, the product of the three function satisfies $h s f = +1$.

Proof: This is satisfied by the triple $(1,2,3)$ for which they are all $+1$. When we negate one of the triple elements, we've mirrored the triple geometrically, so $h$ and $s$ negate but $f$ is sign-independent and stays the same, preserving the equality. When we swap two elements, we negate $h$ and $f$ but keep $s$, again preserving equality. Since these operations suffices to reach any triple, all triples satisfy it.

Now, we use this equality to derive the last element $c$ from the other two elements of the right-handed triple $(a,b,c)$. Right-handed means $h=1$, so we can rewrite the claims as $sf=1$ or $s=f$.

Since $1\times 2 \times 3 = -1 \bmod 7$, we have $s(a,b,c) = -abc$, as each minus sign flips the product.

We can express the chirality $f$ from only $a,b$, since $c$ is forced up to sign, and moreover from $a^2,b^2$, which erases the sign. Squaring mod 7 takes $(1,2,3)$ to $(1,4,2)$, where each element is $4$ times the cyclically previous one modulo 7. So, $b^2/a^2\bmod 7$ is $4$ for this chirality and $2=4^{-1}\bmod 7$ for the opposite one. Therefore, we can find $f$ from the different of this ratio and its inverse:

$$b^2/a^2-a^2/b^2 = 2f \bmod 7$$

and dividing both sides by 2, which is the same as multiplying by -3,

$$-3(b^2/a^2-a^2/b^2) = f \bmod 7$$

Now, plugging expressions into $s=f$ gives

$$abc = 3(b^2/a^2-a^2/b^2). \bmod 7$$

Finally, dividing to isolate $c$ and using the fact the nonzero elements have order 6 modulo 7, so $x^{-3} = x^3$, we get the polynomial expression

$$c=3(a^3b-ab^3)\bmod 7.$$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .