Skip to content

Commit b3084e4

Browse files
committed
New questions
1 parent cf277c4 commit b3084e4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def permutation(lst):
2+
if len(lst) == 0:
3+
return []
4+
if len(lst) == 1:
5+
return [lst]
6+
l = []
7+
for i in range(len(lst)):
8+
m = lst[i]
9+
rem_lst = lst[:i] + lst[i+i:]
10+
for p in permutation(rem_lst):
11+
l.append([m] + p)
12+
return l
13+
14+
15+
data = list('hello world')
16+
for p in permutation(data):
17+
print(p)

0 commit comments

Comments
 (0)