exam: EGMO

problem:
The numbers $p$ and $q$ are prime and satisfy

$$
\frac{p}{p+1}+\frac{q+1}{q}=\frac{2 n}{n+2}
$$

for some positive integer $n$. Find all possible values of $q-p$.
Origin. Luxembourg (Pierre Haas).

solution:
Rearranging the equation, $2 q n(p+1)=(n+2)(2 p q+p+q+1)$. The left hand side is even, so either $n+2$ or $p+q+1$ is even, so either $p=2$ or $q=2$ since $p$ and $q$ are prime, or $n$ is even.

If $p=2,6 q n=(n+2)(5 q+3)$, so $(q-3)(n-10)=36$. Considering the divisors of 36 for which $q$ is prime, we find the possible solutions $(p, q, n)$ in this case are $(2,5,28)$ and $(2,7,19)$ (both of which satisfy the equation).

If $q=2,4 n(p+1)=(n+2)(5 p+3)$, so $n=p n+10 p+6$, a contradiction since $n<p n$, so there is no solution with $q=2$.

Finally, suppose that $n=2 k$ is even. We may suppose also that $p$ and $q$ are odd primes. The equation becomes $2 k q(p+1)=(k+1)(2 p q+p+q+1)$. The left hand side is even and $2 p q+p+q+1$ is odd, so $k+1$ is even, so $k=2 \ell+1$ is odd. We now have

$$
q(p+1)(2 \ell+1)=(\ell+1)(2 p q+p+q+1)
$$

or equivalently

$$
\ell q(p+1)=(\ell+1)(p q+p+1)
$$

Note that $q \mid p q+p+1$ if and only if $q \mid p+1$. Furthermore, because $(p, p+1)=1$ and $q$ is prime, $(p+1, p q+p+1)=(p+1, p q)=(p+1, q)>1$ if and only if $q \mid p+1$.

Since $(\ell, \ell+1)$, we see that, if $q \nmid p+1$, then $\ell=p q+p+1$ and $\ell+1=q(p+1)$, so $q=p+2$ (and $\left(p, p+2,2\left(2 p^{2}+6 p+3\right)\right)$ satisfies the original equation). In the contrary case, suppose $p+1=r q$, so $\ell(p+1)=(\ell+1)(p+r)$, a contradiction since $\ell<\ell+1$ and $p+1 \leq p+r$.

Thus the possible values of $q-p$ are 2,3 and 5 .

problem_match: Problem 5.

solution_match: Solution 1 (submitter).


solution:
Subtracting 2 and multiplying by -1 , the condition is equivalent to

$$
\frac{1}{p+1}-\frac{1}{q}=\frac{4}{n+2}
$$

Thus $q>p+1$. Rearranging,

$$
q-p-1=\frac{4(p+1) q}{n+2}
$$

The expression on the right is a positive integer, and $q$ must cancel into $n+2$ else $q$ would divide $p+1<q$. Let $(n+2) / q=u$ a positive integer.

Now
so

$$
q-p-1=\frac{4(p+1)}{u}
$$

$$
u q-u(p+1)=4(p+1)
$$

so $p+1$ divides $u q$. However, $q$ is prime and $p+1<q$, therefore $p+1$ divides $u$. Let $v$ be the integer $u /(p+1)$. Now

$$
q-p=1+\frac{4}{v} \in\{2,3,5\}
$$

All three cases can occur, where $(p, q, n)$ is $(3,5,78),(2,5,28)$ or $(2,7,19)$. Note that all pairs of twin primes $q=p+2$ yield solutions $\left(p, p+2,2\left(2 p^{2}+6 p+3\right)\right)$.

solution_match: Solution 2 (PSC).


solution:
Subtract 2 from both sides to get

$$
\frac{1}{p+1}-\frac{1}{q}=\frac{4}{n+2}
$$

From this, since $n$ is positive, we have that $q>p+1$. Therefore $q$ and $p+1$ are coprime, since $q$ is prime.
Group the terms on the LHS to get

$$
\frac{q-p-1}{q(p+1)}=\frac{4}{n+2}
$$

Now $(q, q-p-1)=(q, p+1)=1$ and $(p+1, q-p-1)=(p+1, q)=1$ so the fraction on the left is in lowest terms. Therefore the numerator must divide the numerator on the right, which is 4 . Since $q-p-1$ is positive, it must be 1,2 or 4 , so that $q-p$ must be 2,3 or 5 . All of these can be attained, by $(p, q, n)=(3,5,78)$, $(2,5,28)$ and $(2,7,19)$ respectively.

solution_match: Solution 3 (Coordinators).


problem:
There are infinitely many people registered on the social network Mugbook. Some pairs of (different) users are registered as friends, but each person has only finitely many friends. Every user has at least one friend. (Friendship is symmetric; that is, if $A$ is a friend of $B$, then $B$ is a friend of $A$.)

Each person is required to designate one of their friends as their best friend. If $A$ designates $B$ as her best friend, then (unfortunately) it does not follow that $B$ necessarily designates $A$ as her best friend. Someone designated as a best friend is called a 1-best friend. More generally, if $n>1$ is a positive integer, then a user is an $n$-best friend provided that they have been designated the best friend of someone who is an $(n-1)$-best friend. Someone who is a $k$-best friend for every positive integer $k$ is called popular.
(a) Prove that every popular person is the best friend of a popular person.
(b) Show that if people can have infinitely many friends, then it is possible that a popular person is not the best friend of a popular person.

Origin. Romania (Dan Schwarz) (rephrasing by Geoff Smith).
Remark. The original formulation of this problem was:
Given a function $f: X \rightarrow X$, let us use the notations $f^{0}(X):=X, f^{n+1}(X):=f\left(f^{n}(X)\right)$ for $n \geq 0$, and also $f^{\omega}(X):=\bigcap_{n \geq 0} f^{n}(X)$. Let us now impose on $f$ that all its fibres $f^{-1}(y):=\{x \in X \mid f(x)=y\}$, for $y \in f(X)$, are finite. Prove that $f\left(f^{\omega}(X)\right)=f^{\omega}(X)$.

solution:
For any person $A$, let $f^{0}(x)=x$, let $f(A)$ be $A$ 's best friend, and define $f^{k+1}(A)=f\left(f^{k}(A)\right)$, so any person who is a $k$-best friend is $f^{k}(A)$ for some person $A$; clearly a $k$-best friend is also an $\ell$-best friend for all $\ell<k$. Let $X$ be a popular person. For each positive integer $k$, let $x_{k}$ be a person with $f^{k}\left(x_{k}\right)=X$. Because $X$ only has finitely many friends, infinitely many of the $f^{k-1}\left(x_{k}\right)$ (all of whom designated $X$ as best friend) must be the same person, who must be popular.

If people can have infinitely many friends, consider people $X_{i}$ for positive integers $i$ and $P_{i, j}$ for $i<j$ positive integers. $X_{i}$ designates $X_{i+1}$ as her best friend; $P_{i, i}$ designates $X_{1}$ as her best friend; $P_{i, j}$ designates $P_{i+1, j}$ as her best friend if $i<j$. Then all $X_{i}$ are popular, but $X_{1}$ is not the best friend of a popular person.

problem_match: Problem 6.

solution_match: Solution 1 (submitter, adapted).


solution:
For any set $S$ of people, let $f^{-1}(S)$ be the set of people who designated someone in $S$ as their best friend. Since each person has only finitely many friends, if $S$ is finite then $f^{-1}(S)$ is finite.

Let $X$ be a popular person and put $V_{0}=\{X\}$ and $V_{k}=f^{-1}\left(V_{k-1}\right)$. All $V_{i}$ are finite and (since $X$ is popular) nonempty.

If any two sets $V_{i}, V_{j}$, with $0 \leq i<j$ are not disjoint, define $f^{i}(x)$ for positive integers $i$ as in Solution 1 . It follows $\emptyset \neq f^{i}\left(V_{i} \cap V_{j}\right) \subseteq f^{i}\left(V_{i}\right) \cap f^{i}\left(V_{j}\right) \subseteq V_{0} \cap V_{j-i}$, thus $X \in V_{j-i}$. But this means that $f^{j-i}(X)=X$, therefore $f^{n(j-i)}(X)=X$. Furthermore, if $Y=f^{j-i-1}(X)$, then $f(Y)=X$ and $f^{n(j-i)}(Y)=Y$, so $X$ is the best friend of $Y$, who is popular.

If all sets $V_{n}$ are disjoint, by König's infinity lemma there exists an infinite sequence of (distinct) $x_{i}, i \geq 0$, with $x_{i} \in V_{i}$ and $x_{i}=f\left(x_{i+1}\right)$ for all $i$. Now $x_{1}$ is popular and her best friend is $x_{0}=X$.

If people can have infinitely many friends, proceed as in Solution 1.

solution_match: Solution 2 (submitter, adapted).


problem:
Let $A B C$ be an acute-angled triangle with circumcircle $\Gamma$ and orthocentre $H$. Let $K$ be a point of $\Gamma$ on the other side of $B C$ from $A$. Let $L$ be the reflection of $K$ in the line $A B$, and let $M$ be the reflection of $K$ in the line $B C$. Let $E$ be the second point of intersection of $\Gamma$ with the circumcircle of triangle $B L M$. Show that the lines $K H, E M$ and $B C$ are concurrent. (The orthocentre of a triangle is the point on all three of its altitudes.)

Origin. Luxembourg (Pierre Haas).

solution:
Since the quadrilateral $B M E L$ is cyclic, we have $\angle B E M=\angle B L M$. By construction, $|B K|=|B L|=|B M|$, and so (using directed angles)

$$
\begin{aligned}
\angle B L M & =90^{\circ}-\frac{1}{2} \angle M B L=90^{\circ}-\left(180^{\circ}-\frac{1}{2} \angle L B K-\frac{1}{2} \angle K B M\right) \\
& =\left(\frac{1}{2} \angle L B K+\frac{1}{2} \angle K B M\right)-90^{\circ}=\left(180^{\circ}-\angle B\right)-90^{\circ}=90^{\circ}-B .
\end{aligned}
$$

We see also that $\angle B E M=\angle B A H$, and so the point $N$ of intersection of $E M$ and $A H$ lies on $\Gamma$.
Let $X$ be the point of intersection of $K H$ and $B C$, and let $N^{\prime}$ be the point of intersection of $M X$ and $A H$. Since $B C$ bisects the segment $K M$ by construction, the triangle $K X M$ is isosceles; as $A H \| M K, H X N^{\prime}$ is isosceles. Since $A H \perp B C, N^{\prime}$ is the reflection of $H$ in the line $B C$. It is well known that this reflection lies on $\Gamma$, and so $N^{\prime}=N$. Thus $E, M, N$ and $M, X, N^{\prime}$ all lie on the same line $M N$; that is, $E M$ passes through $X$.
![](https://cdn.mathpix.com/cropped/2024_11_22_87b0fcffe09a2a627c59g-3.jpg?height=741&width=1146&top_left_y=1063&top_left_x=455)

Remark (submitter). The condition that $K$ lies on the circumcircle of $A B C$ is not necessary; indeed, the solution above does not use it. However, together with the fact that the triangle $A B C$ is acute-angled, this condition implies that $M$ is in the interior of $\Gamma$, which is necessary to avoid dealing with different configurations including coincident points or the point of concurrence being at infinity.

problem_match: Problem 7.


solution:
We work with directed angles. Let $H K$ meet $B C$ at $X$. Let $M X$ meet $A H$ at $H_{A}$ on $\Gamma$ (where $H_{A}$ is the reflection of $H$ in $B C$ ). Define $E^{\prime}$ to be where $H_{A} M$ meets $\Gamma$ (again). Our task is to show that $\angle M E^{\prime} B=\angle M L B$.

Observe that

$$
\begin{aligned}
\angle M E^{\prime} B & =\angle H_{A} A B & \text { (angles in same segment) } \\
& =B^{c} &
\end{aligned}
$$

Now

$$
\begin{aligned}
\angle M L B & =\angle H L B \\
& =\angle B K H_{C} \\
& =\angle B C H_{C} \\
& =B^{c} .
\end{aligned}
$$

(Simson line, doubled)
(reflecting in the line $A B$ )
(angles in the same segment)


problem:
A word is a finite sequence of letters from some alphabet. A word is repetitive if it is a concatenation of at least two identical subwords (for example, $a b a b a b$ and $a b c a b c$ are repetitive, but $a b a b a$ and $a a b b$ are not). Prove that if a word has the property that swapping any two adjacent letters makes the word repetitive, then all its letters are identical. (Note that one may swap two adjacent identical letters, leaving a word unchanged.)

## Origin. Romania (Dan Schwarz).

solution:
In this and the subsequent solutions we refer to a word with all letters identical as constant.

Let us consider a nonconstant word $W$, of length $|W|=w$, and reach a contradiction. Since the word $W$ must contain two distinct adjacent letters, be it $W=A a b B$ with $a \neq b$, we may assume $B=c C$ to be non-empty, and so $W=A a b c C$. By the proper transpositions we get the repetitive words $W^{\prime}=A b a c C=P^{w / p}$, of a period $P$ of length $p \mid w, 1<p<w$, and $W^{\prime \prime}=A a c b C=Q^{w / q}$, of a period $Q$ of length $q \mid w, 1<q<w$. However, if a word $U V$ is repetitive, then the word $V U$ is also repetitive, of a same period length; therefore we can work in the sequel with the repetitive words $W_{0}^{\prime}=C A b a c$, of a period $P^{\prime}$ of length $p$, and $W_{0}^{\prime \prime}=C A a c b$, of a period $Q^{\prime}$ of length $q$. The main idea now is that the common prefix of two repetitive words cannot be too long.

Now, if a word $a_{1} a_{2} \ldots a_{w}=T^{w / t}$ is repetitive, of a period $T$ of length $t \mid w, 1 \leq t<w$, then the word (and any subword of it) is $t$-periodic, i.e. $a_{k}=a_{k+t}$, for all $1 \leq k \leq w-t$. Therefore the word $C A$ is both $p$-periodic and $q$-periodic.

We now use the following classical result:
Wilf-Fine Theorem. Let $p, q$ be positive integers, and let $N$ be a word of length $n$, which is both p-periodic and $q$-periodic. If $n \geq p+q-\operatorname{gcd}(p, q)$ then the word $N$ is $\operatorname{gcd}(p, q)$-periodic (but this need not be the case if instead $n \leq p+q-\operatorname{gcd}(p, q)-1)$.

By this we need $|C A| \leq p+q-\operatorname{gcd}(p, q)-1 \leq p+q-2$, hence $w \leq p+q+1$, otherwise $W_{0}^{\prime}$ and $W_{0}^{\prime \prime}$ would be identical, absurd. Since $p \mid w$ and $1<p<w$, we have $2 p \leq w \leq p+q+1$, and so $p \leq q+1$; similarly we have $q \leq p+1$.

If $p=q$, then $|C A| \leq p+p-\operatorname{gcd}(p, p)-1=p-1$, so $2 p \leq w \leq p+2$, implying $p \leq 2$. But the three-letter suffix $a c b$ is not periodic (not even for $c=a$ or $c=b$ ), thus must be contained in $Q^{\prime}$, forcing $q \geq 3$, contradiction.

If $p \neq q$, then $\max (p, q)=\min (p, q)+1$, so $3 \min (p, q) \leq w \leq 2 \min (p, q)+2$, hence $\min (p, q) \leq 2$, forcing $\min (p, q)=2$ and $\max (p, q)=3$; by an above observation, we may even say $q=3$ and $p=2$, leading to $c=b$. It follows $6=3 \min (p, q) \leq w \leq 2 \min (p, q)+2=6$, forcing $w=6$. This leads to $C A=a b a=a b b$, contradiction.

problem_match: Problem 8.


solution:
We will take over from the solution above, just before invoking the Wilf-Fine Theorem, by replacing it with a weaker lemma, also built upon a seminal result of combinatorics on words.

Lemma. Let $p, q$ be positive integers, and let $N$ be a word of length $n$, which is both $p$-periodic and $q$ periodic. If $n \geq p+q$ then the word $N$ is $\operatorname{gcd}(p, q)$-periodic.

Proof. Let us first prove that two not-null words $U, V$ commute, i.e. $U V=V U$, if and only if there exists a word $W$ with $|W|=\operatorname{gcd}(|U|,|V|)$, such that $U=W^{|U| /|W|}, V=W^{|V| /|W|}$. The "if" part being trivial, we will prove the "only if" part, by strong induction on $|U|+|V|$. Indeed, for the base step $|U|+|V|=2$ we have $|U|=|V|=1$, and so clearly we can take $W=U=V$. Now, for $|U|+|V|>2$, if $|U|=|V|$ it follows $U=V$, and so we can again take $W=U=V$. If not, assume without loss of generality $|U|<|V|$; then $V=U V^{\prime}$, so $U U V^{\prime}=U V^{\prime} U$, whence $U V^{\prime}=V^{\prime} U$. Since $\left|V^{\prime}\right|<|V|$, it follows $2 \leq|U|+\left|V^{\prime}\right|<|U|+|V|$, so by the induction hypothesis there exists a suitable word $W$ such that $U=W^{|U| /|W|}, V^{\prime}=W^{\left|V^{\prime}\right| /|W|}$, so $V=U V^{\prime}=W^{|U| /|W|} W^{\left|V^{\prime}\right| /|W|}=W^{\left(|U|+\left|V^{\prime}\right|\right) /|W|}=W^{|V| /|W|}$.

Now, assuming without loss of generality $p \leq q, q=k p+r$, we have $N=Q P S$, with $|Q|=q,|P|=p$. If $r=0$ all is clear; otherwise it follows we can write $P=U V, Q=V(U V)^{k}$, with $|V|=r$, whence $U V=V U$, implying $P Q=Q P$, and so by the above result there will exist a word $W$ of length $\operatorname{gcd}(p, q)$ such that $P=W^{p / \operatorname{gcd}(p, q)}$, $Q=W^{q / \operatorname{gcd}(p, q)}$, therefore $N$ is $\operatorname{gcd}(p, q)$-periodic.

By this we need $|C A| \leq p+q-1$, hence $w \leq p+q+2$, otherwise by the previous lemma $W_{0}^{\prime}$ and $W_{0}^{\prime \prime}$ would be identical, absurd. Since $p \mid w$ and $1<p<w$, we have $2 p \leq w \leq p+q+2$, and so $p \leq q+2$; similarly we have $q \leq p+2$. That implies $\max (p, q) \leq \min (p, q)+2$. Now, from $k \max (p, q)=w \leq p+q+2 \leq 2 \max (p, q)+2$ we will have $(k-2) \max (p, q) \leq 2$; but $\max (p, q) \leq 2$ is impossible, since the three-letter suffix $a c b$ is not periodic (not even for $c=a$ or $c=b$ ), thus must be contained in $Q^{\prime}$, forcing $q \geq 3$. Therefore $k=2$, and so $w=2 \max (p, q)$.

If $\max (p, q)=\min (p, q)$, then $w=2 p=2 q$, for a quick contradiction.
If $\max (p, q)=\min (p, q)+1$, it follows $3 \min (p, q) \leq w=2 \max (p, q)=2 \min (p, q)+2$, hence $\min (p, q) \leq 2$, forcing $\min (p, q)=2$ and $\max (p, q)=3$; by an above observation, we may even say $q=3$ and $p=2$, leading to $c=b$. It follows $w=2 \max (p, q)=6$, leading to $C A=a b a=a b b$, contradiction.

If $\max (p, q)=\min (p, q)+2$, it follows $3 \min (p, q) \leq w=2 \max (p, q)=2 \min (p, q)+4$, hence $\min (p, q) \leq 4$. From $\min (p, q) \mid w=2 \max (p, q)$ then follows either $\min (p, q)=2$ and $\max (p, q)=4$, thus $w=8$, clearly contradictory, or else $\min (p, q)=4$ and $\max (p, q)=6$, thus $w=12$, which also leads to contradiction, by just a little deeper analysis.

solution_match: Solution 2 (submitter).


solution:
We define the distance between two words of the same length to be the number of positions in which those two words have different letters. Any two words related by a transposition have distance 0 or 2 ; any two words related by a sequence of two transpositions have distance $0,2,3$ or 4 .

Say the period of a repetitive word is the least $k$ such that the word is the concatenation of two or more identical subwords of length $k$. We use the following lemma on distances between repetitive words.

Lemma. Consider a pair of distinct, nonconstant repetitive words with periods ga and gb, where $(a, b)=1$ and $a, b>1$, the first word is made up of $k b$ repetitions of the subword of length ga and the second word is made up of ka repetitions of the subword of length gb . These two words have distance at least $\max (k a, k b)$.

Proof. We may assume $k=1$, since the distance between the words is $k$ times the distance between their initial subwords of length $g a b$. Without loss of generality suppose $b>a$.

For each positive integer $m$, look at the subsequence in each word of letters in positions congruent to $m$ $(\bmod g)$. Those subsequences (of length $a b)$ have periods dividing $a$ and $b$ respectively. If they are equal, then they are constant (since each letter is equal to those $a$ and $b$ before and after it, mod $a b$, and $(a, b)=1$ ). Because $a>1$, there is some $m$ for which the first subsequence is not constant, and so is unequal to the second subsequence. Restrict attention to those subsequences.

We now have two distinct repetitive words, one (nonconstant) made up of $b$ repetitions of a subword of length $a$ and one made up of $a$ repetitions of a subword of length $b$. Looking at the first of those words, for any $1 \leq t \leq b$ consider the letters in positions $t, t+b, \ldots, t+(a-1) b$. These letters cover every position (mod $a)$; since the first word is not constant, the letters are not all equal, but the letters in the corresponding positions in the second word are all equal. At least one of these letters in the first word must change to make them all equal to those in the corresponding positions in the second word; repeating for each $t$, at least $b$ letters must change, so the words have distance at least $b$.

In the original problem, consider all the words (which we suppose to be repetitive) obtained by a transposition of two adjacent letters from the original nonconstant word; say that word has length $n$. Suppose those words include two distinct words with periods $n / a$ and $n / b$; those words have distance at most 4 . If $a>4$ or $b>4$, we have a contradiction unless $a \mid b$ or $b \mid a$. If $a>4$ is the greatest number of repetitions in any of the words ( $n / a$ is the smallest period), then unless all the numbers of repetitions divide each other there must be words with 2 or 4 repetitions, words with 3 repetitions and all larger numbers of repetitions must divide each other and be divisible by 6 .

We now divide into three cases: all the numbers of repetitions may divide either other; or there may be words with (multiples of) 2,3 and 6 repetitions; or all words may have at most 4 repetitions, with at least one word having 3 repetitions and at least one having 2 or 4 repetitions.

Case 1. Suppose all the numbers of repetitions divide each other. Let $k$ be the least number of repetitions. Consider the word as being divided into $k$ blocks, each of $\ell$ letters; any transposition of two adjacent letters leaves those blocks identical. If any two adjacent letters within a block are the same, then this means all the blocks are already identical; since the word is not constant, the letters in the first block are not all identical, so there are two distinct adjacent letters in the first block, and transposing them leaves it distinct from the other blocks, a contradiction. Otherwise, all pairs of adjacent letters within each block are distinct; transposing any adjacent pair within the first block leaves it identical to the second block. If the first block has more than two letters, this is impossible since transposing the first two letters has a different result from transposing the second two. So the blocks all have length 2 ; similarly, there are just two blocks, the arrangement is $a b b a$ but transposing the adjacent letters $b b$ does not leave the word repetitive.

Case 2. Suppose some word resulting from a transposition is made of (a multiple of) 6 repetitions, some of 3 repetitions and some of 2 repetitions (or 4 repetitions, counted as 2 ). Consider it as a sequence of 6 blocks, each of length $\ell$. If the six blocks are already identical, then as the word is not constant, there are some two distinct adjacent letters within the first block; transposing them leaves a result where the blocks form a
pattern $B A A A A A$, which cannot have two, three or six repetitions. So the six blocks are not already identical. If a transposition within a block results in them being identical, the blocks form a pattern (without loss of generality) $B A A A A A, A B A A A A$ or $A A B A A A$. In any of these cases, apply the same transposition (that converts between $A$ and $B$ ) to an $A$ block adjacent to the $B$ block, and the result cannot have two, three or six repetitions. Finally, consider the case where some transposition between two adjacent blocks results in all six blocks being identical. The patterns are $B C A A A A, A B C A A A$ and $A A B C A A$ (and considering the letters at the start and end of each block shows $B \neq C$ ). In all cases, transposing two adjacent distinct letters within an $A$ block produces a result that cannot have two, three or six repetitions.

Case 3. In the remaining case, all words have at most 4 repetitions, at least one has 3 repetitions and at least one has 2 or 4 repetitions. For the purposes of this case we will think of 4 -repetition words as being 2 -repetition words. The number of each letter is a multiple of 6 , so $n \geq 12$; consider the word as made of six blocks of length $\ell$.

If the word is already repetitive with 2 repetitions, pattern $A B C A B C$, any transposition between two distinct letters leaves it no longer repetitive with two repetitions, so it must instead have three repetitions after the transposition. If $A B$ is not all one letter, transposing two adjacent letters within $A B$ implies that $C A=B C$, so $A=B=C$, the word has pattern $A A A A A A$ but transposing within the initial $A A$ means it no longer has 3 repetitions. This implies that $A B$ is all one letter, but similarly $B C$ must also be all one letter and so the word is constant, a contradiction.

If the word is already repetitive with 3 repetitions, it has pattern $A B A B A B$ and any transposition leaves it no longer having 3 repetitions, so having 2 repetitions instead. $A B A$ is not made all of one letter (since the word is not constant) and any transposition between two adjacent distinct letters therein turns it into $B A B$; such a transposition affects at most two of the blocks, so $A=B$, the word has pattern $A A A A A A$ and transposing two adjacent distinct letters within the first half cannot leave it with two repetitions.

So the word is not already repetitive, and so no two adjacent letters are the same; all transpositions give distinct strings. Consider transpositions of adjacent letters within the first four letters; three different words result, of which at most one is periodic with two repetitions (it must be made of two copies of the second half of the word) and at most one is periodic with three repetitions, a contradiction.

solution_match: Solution 3 (PSC).