A string of length n on an alphabet l of m characters is an arrangement of n not necessarily distinct symbols from l. There are m^n such distinct strings.

For example, the strings of length n=3 on the alphabet {1,2} are {1,1,1}, {1,1,2}, {1,2,1}, {1,2,2}, {2,1,1}, {2,1,2}, {2,2,1}, and {2,2,2}.

In the Wolfram Language, strings of length n in the alphabet consisting of the members of a list l can be enumerated using Tuples[list, n].

See also

Alphabet, Ball Picking, Binomial Coefficient, Choose, Combination, List, Multichoose, Multinomial Coefficient, Multiset, n-Tuple, Permutation, Substring, Word

Explore with Wolfram|Alpha


Skiena, S. "Strings." §1.5.1 in Implementing Discrete Mathematics: Combinatorics and Graph Theory with Mathematica. Reading, MA: Addison-Wesley, p. 40, 1990.

Referenced on Wolfram|Alpha


Cite this as:

Weisstein, Eric W. "String." From MathWorld--A Wolfram Web Resource.

Subject classifications