Examples

1. Total Number of Strings

How many -length strings are there over an alphabet of size ?


2. Strings Where Each Character Is Used at Least Once

Let the alphabet be and string length be 12.
We want to count strings where each character appears at least once.

This is equivalent to:

For and :


Set Interpretation

Let:

  • : strings where a is used at least once
  • : strings where b is used at least once
  • : strings where c is used at least once

We want:

Using Demorgan’s Law:

Expanding:

Where:

  • = strings without a
  • = strings without b
  • = strings without c

Final result:

See Set Theory for more information