Problem: Each of eight boxes contains six balls.
Each ball has been colored with one of $n$ colors,
such that no two balls in the same box are the same color,
and no two colors occur together in more than one box.
Find with proof the smallest possible $n$.

Solution: The answer is $n = 23$.
Shown below is a construction using that many colors,
which we call $\{1,2,\dots,15,a,\dots,f,X,Y\}$.
\[
  \begin{bmatrix}
    X & X & X & 1 & 2 & 3 & 4 & 5 \\
    1 & 6 & 11 & 6 & 7 & 8 & 9 & 10 \\
    2 & 7 & 12 & 11 & 12 & 13 & 14 & 15 \\
    3 & 8 & 13 & Y & Y & Y & a & b \\
    4 & 9 & 14 & a & c & e & c & d \\
    5 & 10 & 15 & b & d & f & e & f
  \end{bmatrix}
\]
We present now two proofs that $n = 23$ is best possible.
I think the first is more motivated --- it will
actually show us how we could come up with the example above.

\paragraph{First solution (hands-on).}
We say a color $x$ is \emph{overrated}
if it is used at least three times.
First we make the following smoothing argument.
\begin{claim*}
  Suppose some box contains a ball of overrated color $x$
  plus a ball of color $y$ used only once.
  Then we can change one ball of color $x$ to color $y$
  while preserving all the conditions.
\end{claim*}
\begin{proof}
  Obvious.
  (Though the color $x$ could cease to be overrated after this operation.)
\end{proof}
By applying this operation as many times as possible,
we arrive at a situation in which whenever we have
a box with an overrated color,
the other colors in the box are used twice or more.

Assume now $n \le 23$ and the assumption;
we will show the equality case must of the form we gave.
Since there are a total of $48$ balls,
at least two colors are overrated.
Let $X$ be an overrated color and take three boxes where it appears.
Then there are $15$ more distinct colors, say $\{1, \dots, 15\}$
lying in those boxes.
Each of them must appear at least once more,
so we arrive at the situation
\[
  \begin{bmatrix}
    X & X & X & 1 & 2 & 3 & 4 & 5 \\
    1 & 6 & 11 & 6 & 7 & 8 & 9 & 10 \\
    2 & 7 & 12 & 11 & 12 & 13 & 14 & 15 \\
    3 & 8 & 13 \\
    4 & 9 & 14 \\
    5 & 10 & 15 \\
  \end{bmatrix}
\]
up to harmless permutation of the color names.
Now, note that none of these $15$ colors can reappear.
So it remains to fill up the last five boxes.

Now, there is at least one more overrated color,
distinct from any we have seen; call it $Y$.
In the three boxes $Y$ appears in,
there must be six new colors,
and this gives the lower bound $n \ge 1 + 15 + 1 + 6 = 23$
which we sought,
with equality occurring as we saw above.

\begin{remark*}
  [Partial progresses]
  The fact that $\binom{16}{2} = 120 = 8 \binom{6}{2}$
  (suggesting the bound $n \ge 16$) is misleading
  and not that helpful.

  There is a simple argument showing that $n$
  should be much larger than $16$.
  Imagine opening the boxes in any order.
  The first box must contain six new colors.
  The second box must contain five new colors,
  and so on; thus $n \ge 6 + 5 + 4 + 3 + 2 + 1 = 21$.
  This is sharp for seven boxes, as the example below shows.
  \[
    \begin{bmatrix}
      1 & 1 & 2 & 3 & 4 & 5 & 6 \\
      2 & 7 & 7 & 8 & 9 & 10 & 11 \\
      3 & 8 & 12 & 12 & 13 & 14 & 15 \\
      4 & 9 & 13 & 16 & 16 & 17 & 18 \\
      5 & 10 & 14 & 17 & 19 & 19 & 20 \\
      6 & 11 & 15 & 18 & 20 & 21 & 21
    \end{bmatrix}
  \]
  However, one cannot add an eight box,
  suggesting the answer should be a little larger than $21$.
  One possible eight box is $\{1,12,19,a,b,c\}$
  which gives $n \le 24$; but the true answer is a little trickier.
\end{remark*}

\paragraph{Second solution (slick).}
Here is a short proof from the official solutions of the bound.
Consider the $8 \times 6$ grid of colors as before.
For each ball $b$, count the number of times $n_b$ its color is used,
and write the fraction $\frac{1}{n_b}$.

On the one hand, we should have
\[ n = \sum_{\text{all $48$ balls $b$}} \frac{1}{n_b}. \]
On the other hand, for any given box $B$, we have
$\sum_{b \in B} (n_b-1) \le 7$, as among the other seven boxes
at most one color from $B$ appears.
Therefore, $\sum_{b \in B} n_b \le 13$,
and a smoothing argument this implies
\[ \sum_{b \in B} \frac{1}{n_b} \ge \frac13 \cdot 1 + \frac12 \cdot 5
  = \frac{17}{6}. \]
Thus, $n \ge 8 \cdot \frac{17}{6} = 22.66\dots$, so $n \ge 23$.