python all permutations of a string
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
python all permutations of a string
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
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 ' )
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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us