Learn / Library / Combinatorics
No equal neighbours
How many distinct strings use all letters of (where , and each appear times) so that no equal letters are next to each other?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Use inclusion-exclusion on which repeated letters end up adjacent; a glued pair behaves as one object.
Solution
- Without restrictions there are strings.
- Call a letter glued when its copies are adjacent. Gluing a chosen set of letters leaves objects with letters still repeated, giving strings.
- For this is for each of the letters, for it is for each of the choices, and for it is .
- By inclusion-exclusion the answer is .
Answer: