Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def permute(s):
- if len(s)==0:
- return ['']
- head,tail=s[0],s[1:]
- tail_permutation=permute(tail)
- if head.isalpha():
- u,l=head.upper(),head.lower()
- return map(u.__add__, tail_permutation) + map(l.__add__, tail_permutation)
- else:
- return map(head.__add__, tail_permutation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement