Skip to content
Quantoros

Form five-character strings without repeats from a,...,h. How many do not contain the contiguous substring bad?

Quant ResearchLevel: IntermediateForbidden substring counting

Form five-character strings without repeats from a,...,h. How many do not contain the contiguous substring bad?

Hints
  • Count all strings then subtract forbidden ones.
  • Compress the fixed three-letter substring into one block.

Answer

Total 87654=6720. Treat bad as a block: choose its start in 3 ways and fill the two remaining positions with an ordered pair from five unused letters, 5*4. Bad strings total 60, so 6660 remain. No string can contain bad twice.

Source and licence: Oscar Levin — Discrete Mathematics: An Open Introduction, 3rd edition · CC-BY-SA-4.0 · answer: Quantoros editorial

Related questions