Answers for "find all permutations of a given string"

1

python all permutations of a string

>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
Posted by: Guest on November-08-2020
0

get all permutations of string

# get all permutations of string
import itertools
for p in itertools.permutations('123'):
    print(p)					# ( ' 1 ', ' 2 ', ' 3 ') ( ' 1 ' , ' 3 ', ' 2 ' ) ( ' 2 ', ' 1 ', ' 3 ' )
Posted by: Guest on March-21-2022
0

how to print all permutations of a string

void permutation(string s)
{
    sort(s.begin(),s.end());
	do{
		cout << s << " ";
	}
    while(next_permutation(s.begin(),s.end()); // std::next_permutation
    
    cout << endl;
}
Posted by: Guest on September-29-2020

Code answers related to "find all permutations of a given string"

Python Answers by Framework

Browse Popular Code Answers by Language