Код: Выделить всё
import itertools
def permutations_in_dict(string, words):
'''
Parameters
----------
string : {str}
words : {set}
Returns
-------
list : {list} of {str}
Example
-------
>>> permutations_in_dict('act', {'cat', 'rat', 'dog', 'act'})
['act', 'cat']
'''
Код: Выделить всё
return list(set([''.join(p) for p in itertools.permutations(string)]) & words)
Подробнее здесь: https://stackoverflow.com/questions/448 ... rmutations
Мобильная версия