5. Kira has 3 blocks with the letter A, 3 blocks with the letter B, and 3 blocks with the letter C. She places these 9 blocks in a row. She wants to have as many different distances between blocks with the same letter as possible. For example, in the sequence ABCAABCBC, the blocks with the letter A have distances of 1, 3, and 4 from each other, the blocks with the letter B have distances of 2, 4, and 6 from each other, and the blocks with the letter C also have distances of 2, 4, and 6 from each other. Altogether, the distances 1, 2, 3, 4, and 6 appear; that makes 5 different distances. What is the maximum number of different distances that can occur?
5. We will show that there can be a maximum of 7 different distances. First, we prove that the number of different distances cannot be more than 7, then we show that there is a sequence of blocks with 7 different distances.

The possible distances between two blocks in a row of nine blocks are 1 through 8. Therefore, there can certainly not be more than 8 different distances. We will show that there is always at least one distance that does not occur.

If in a sequence the distances 8 and 7 do not both occur, then we are done. Suppose, however, that we have a sequence in which they do both occur. Distance 8 can only occur between the first and the last block, so these get the same letter, say A. Distance 7 can only occur between either the first and the eighth (second-to-last) block, or between the second and the last block. Since the two outer blocks are already A, the second or the eighth block must also be A. The sequence of blocks is thus AAxxxxxxA (or conversely: AxxxxxxAA), where the x's are filled with blocks B and C. We now see that distance 6 cannot occur anymore: the distances between the A's are 1, 7, and 8, and the distances between the B's and C's among themselves are not higher than 5. Here, too, there is thus at least one possible distance that does not occur.

We conclude that there is always one distance from the possible distances $1,2,3,4,5,6,7,8$ that does not occur. The number of different distances can therefore not be more than 7.

An example of a sequence of blocks in which 7 different distances occur is ABBCACCBA, with mutual distances $4,4,8 ; 1,5,6 ; 1,2,3$ (only distance 7 is missing). Therefore, the maximum number of different distances that can occur is equal to 7.