Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rec_permutations(n):
- s = ''
- for i in n:
- s += str(i)
- L = []
- if len(s) == 1:
- return [s]
- else:
- for x in s:
- for a in rec_permutations(s.replace(x, "")):
- L.append(x + a)
- return L
- print(
- '\n'.join(
- ' '.join(str_subset) for str_subset in[
- map(str, sorted_subset) for sorted_subset in sorted(rec_permutations("567"))
- ]
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement