Every month, IBM Research hosts the Ponder This challenge, which usually can be solved with pure mathematics but is often easier if combined with a little programming.
The problem immediately reminded me of combinatorial design. Designs are related to projective planes, which the official solution used. They’re also related to codes, which is the approach I used.
Suppose we encode each cube as a binary vector of length N, where \(N \le 32\) is the number of digits needed for a solution. Each position of the vector will be 1 if the digit appears on a face of the cube, and 0 otherwise.
Each cube is then a vector with Hamming weight 6 because there are 6 faces on the cube, each with a distinct digit. The Hamming distance between any pair of cube vectors is 10, because the cubes have exactly one digit in common: They are equal in that position, different in the other 5 digit positions (where the cube with that digit has a 1 and the other cube has a 0) for a total of 10 positions where they differ, and equal in all the other positions (where they are both 0).
Consequently, a solution to this challenge is equivalent to constructing a constant-weight code with weight 6, distance 10, and at least 25 codewords.
The maximum number of codewords in such a code is written \(A(n, d, w)\), so we want to find the smallest n such that \(A(n, 10, 6) \ge 25\) and then give an example of such a code with exactly 25 codewords.
According to this research page by Andries E. Brouwer, there is a code such that \(A(30,10,6) = 25\). Thus, there exists a solution with 30 digits.
The superscript s indicates that this corresponds to a shortened (31,10,6) or (31,11,6) code, and links to another table. At this point, I became stuck in the theory, and spent some time exploring some Galois field structures (including working through this 1979 paper by Graham & Sloane), before realizing that I have forgotton most of the coding theory I learned in a EE/CS/MA class at Caltech over 20 years ago.
I then switched over to a combination of manual reasoning and software. I started out by designing the first five codewords by hand, so that each word has weight 6 and each pair of words has distance 10:
where the question marks indicate unknown values. At this point, the search space was small enough to allow a quick brute-force software approach to find the remaining unknown values:
And finally, convert that solution into the required submission format: