Function Resource

StringPermutations

Gives the specified character permutations for a string

ResourceFunction["StringPermutations"][string]

generates a list of all possible permutations of the characters in string.

ResourceFunction["StringPermutations"][string,n]

gives all permutations containing at most n characters.

ResourceFunction["StringPermutations"][string,n]

gives all permutations containing exactly n characters.

Details and Options

StringPermutations is implemented with Characters and Permutations.
StringPermutations is the string analog of Permutations of a list.

Examples

Basic Examples

Permutations of "cat":

In[1]:=
ResourceFunction[ "https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Function/\
StringPermutations"]["cat"]
Out[1]=

Three character permutations of "horse":

In[2]:=
ResourceFunction[ "https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Function/\
StringPermutations"]["horse", {3}]
Out[2]=

One, two, and three character permutations of "garden":

In[3]:=
ResourceFunction[ "https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Function/\
StringPermutations"]["garden", 3]
Out[3]=