在这个 kata 中,您必须创建非空输入字符串的所有排列并删除重复项(如果存在)。这意味着,您必须以所有可能的顺序对输入中的所有字母进行洗牌。
例子:
* With input 'a' * Your function should return: ['a'] * With input 'ab' * Your function should return ['ab', 'ba'] * With input 'aabb' * Your function should return ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']
排列顺序不一定;
import itertools as it
string = 'aabb'
le = len(string)
res = []
for s in it.permutations(string, le):
res.append(''.join(s))
res = list(set(res))
print(res)



