18. [10] For any positive integer $x$, define Accident $(x)$ to be the set of ordered pairs $(s, t)$ with $s \in$ $\{0,2,4,5,7,9,11\}$ and $t \in\{1,3,6,8,10\}$ such that $x+s-t$ is divisible by 12 . For any nonnegative integer $i$, let $a_{i}$ denote the number of $x \in\{0,1, \ldots, 11\}$ for which $|\operatorname{Accident}(x)|=i$. Find
$$
a_{0}^{2}+a_{1}^{2}+a_{2}^{2}+a_{3}^{2}+a_{4}^{2}+a_{5}^{2} .
$$
Answer: 26 Modulo twelve, the first set turns out to be $\{-1 \cdot 7,0 \cdot 7, \ldots, 5 \cdot 7\}$ and the second set turns out to be be $\{6 \cdot 7, \ldots, 10 \cdot 7\}$. We can eliminate the factor of 7 and shift to reduce the problem to $s \in\{0,1, \ldots, 6\}$ and $t \in\{7, \ldots, 11\}$. With this we can easily compute $\left(a_{0}, a_{1}, a_{2}, a_{3}, a_{4}, a_{5}\right)=$ $(1,2,2,2,2,3)$. Therefore, the answer is 26 .

It turns out that the choice of the sets correspond to the twelve keys of a piano in an octave. The first set gives the locations of the white keys, while the second set gives the location of the black keys. Steps of seven then correspond to perfect fifths. See, for example:
- http://en.wikipedia.org/wiki/Music_and_mathematics
- http://en.wikipedia.org/wiki/Guerino_Mazzola