Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def permute(s):
  2.     if len(s)==0:
  3.         return ['']
  4.     head,tail=s[0],s[1:]
  5.  
  6.     tail_permutation=permute(tail)
  7.  
  8.     if head.isalpha():
  9.         u,l=head.upper(),head.lower()
  10.         return map(u.__add__, tail_permutation) + map(l.__add__, tail_permutation)
  11.     else:
  12.         return map(head.__add__, tail_permutation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement