1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
def (xs): if isinstance(xs,str): def str2charArray(str): charArray = [] for i in str: charArray.append(i) return charArray xs = str2charArray(xs)
if len(xs) == 0 or len(xs) == 1: return [xs]
result = []
for i in range(0,len(xs)): temp_list = xs[:] temp_list.pop(i) temp = permutation(temp_list) for j in temp: j.insert(0,xs[i]) result.append(j)
return result
|
近期评论