Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def perm_pearl(m):
- def perm_sub(n, a):
- if n == m:
- print(a)
- else:
- for x in range(2, m + 1):
- if x not in a:
- if n != 2 or a[0] > x:
- a.append(x)
- perm_sub(n + 1, a)
- a.pop()
- for x in range(2, m + 1):
- perm_sub(2, [x, 1])
- if __name__ == '__main__':
- print(perm_pearl(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement