25 lines
		
	
	
		
			473 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			25 lines
		
	
	
		
			473 B
		
	
	
	
		
			Python
		
	
	
	
	
	
|   | 
 | ||
|  | def permutation(mot): | ||
|  |     """find all permutation of a word
 | ||
|  | 
 | ||
|  |     :mot: TODO | ||
|  |     :returns: list of all permutations | ||
|  | 
 | ||
|  |     """
 | ||
|  |     return permutation_rec('' , mot) | ||
|  | 
 | ||
|  | def permutation_rec(pre, post): | ||
|  |     print(pre, post) | ||
|  |     if (post == ''): | ||
|  |         return pre | ||
|  |     ret = list() | ||
|  |     for i in list(post): | ||
|  |         _post = list(post) | ||
|  |         _post.remove(i) | ||
|  |         ret.append(permutation_rec(pre + i, str(_post))) | ||
|  |     return ret | ||
|  | 
 | ||
|  | if __name__ == "__main__": | ||
|  |     permutation('abc') | ||
|  | 
 |