Problem

Source: 2001 Estonia National Olympiad Final Round grade 10 p5

Tags: Words, combinatorics



A tribe called Ababab uses only letters $A$ and $B$, and they create words according to the following rules: (1) $A$ is a word; (2) if $w$ is a word, then $ww$ and $w\overline{w}$ are also words, where $\overline{w}$ is obtained from $w$ by replacing all letters $A$ with $B$ and all letters $B$ with $A$ ( $xy$ denotes the concatenation of $x$ and $y$) (3) all words are created by rules (1) and (2). Prove that any two words with the same number of letters differ exactly in half of their letters.