Hacker News new | past | comments | ask | show | jobs | submit login

Quick and Dirty(probably better ways to do it):

  def permute(string, prefix = ''):
        if len(string) == 1:
  		print prefix + string
  		return
  
        for x in range(0, len(string)):
  		new_prefix = prefix + string[x]
  		unused_chars = string[0:x] + string[x+1:]
  		permute(unused_chars, new_prefix)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: