# Enigmatic Code

Programming Enigma Puzzles

## Enigma 978: The ABC brick company

From New Scientist #2133, 9th May 1998 [link]

The ABC brick company prides itself on making unique toys. It has just produced a range of wooden bricks, all of the same size, in the shape of a tetrahedron (a solid with four equilateral-triangle faces). Each of the four faces on every tetrahedron is painted in one of the company’s standard colour range. For example, one of the bricks has one yellow face, two blue faces, and a green face. The company ensures that each tetrahedron is different — there is no way of rotating one to make it look like another. With that restriction in mind, the company has manufactured the largest possible number of these bricks.

To add to the uniqueness of the toys, each brick is placed in an individual cardboard box with the letters “ABC” stencilled on it. Then using the same standard range of the company’s colours, an artist paints each of the letters on the boxes. For example, one has a red “A”, a blue “B”, and a red “C”. No two of the colourings of the ABCs are the same, and, with that restriction in mind, once again the company has produced the largest possible number of boxes.

By coincidence, there are just enough boxes to put one of the tetrahedra in each.

How many colours are there in the company’s standard range?

#### News

There are now 450 Enigma puzzles remaining to post, which means that 75% of all Enigma puzzles are now available on the site.

[enigma978]

### One response to “Enigma 978: The ABC brick company”

1. Jim Randell 27 December 2019 at 8:45 am

If there are n colours available to colour the three letters ABC, then there are different colourings.

This Python program counts the number of distinguishable ways to colour a tetrahedron with n colours, and looks for the first instance (where n ≥ 3) of this number being equal to .

It runs in 695ms.

Run: [ @repl.it ]

```from enigma import irange, inf, subsets, printf

# how the rotations of a tetrahedron permute the faces
rots = [
(0, 1, 2, 3), (0, 2, 3, 1), (0, 3, 1, 2),
(1, 0, 3, 2), (1, 2, 0, 3), (1, 3, 2, 0),
(2, 0, 1, 3), (2, 1, 3, 0), (2, 3, 0, 1),
(3, 0, 2, 1), (3, 1, 0, 2), (3, 2, 1, 0),
]

# calculate the number of colourings of a tetrahedron with n colours available
def tetra(n):
s = set()
for cs in subsets(irange(1, n), size=4, select="M"):
s.add(min(tuple(cs[i] for i in rs) for rs in rots))
return len(s)

# choose the number of colours
for n in irange(3, inf):
t = tetra(n)
assert 12 * t == n * n * (n * n + 11)
printf("tetra({n}) = {t}")
if t == n ** 3: break
```

Solution: There are 11 colours in the company’s standard range.

Analytically:

The number of distinguishable ways to colour a tetrahedron with n colours is given by:

tetra(n) = C(n, 1) + 3C(n, 2) + 3C(n, 3) + 2C(n, 4)

which is the number of ways to colour the tetrahedron using exactly 1, 2, 3, 4 (of n) colours.

Which can be written as:

tetra(n) = n² (n² + 11) / 12

(see: OEIS A006008).

We are interested in when:

tetra(n) = n³
n ≥ 3

So:

n² (n² + 11) = 12n³
n² (n² – 12n + 11) = 0
n² (n – 1) (n – 11) = 0

Which has roots at n = 0, n = 1, n = 11.

We are told there are at least 3 colours, so we want the largest of these solutions.

This site uses Akismet to reduce spam. Learn how your comment data is processed.