In this kata you have to create all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders.

Examples:

```python
permutations('a'); # ['a']
permutations('ab'); # ['ab', 'ba']
permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']
```

The order of the permutations doesn't matter.

Source: codewars | Difficulty: MEDIUM
Tags: String algorithms

Combinatorics

Starter code: def permutations(string):
	

Solutions:
import itertools

def permutations(string):
	return list((''.join(p) for p in set(itertools.permutations(string))))


def permutations(string):
	if len(string) == 1:
		return set(string)
	first = string[0]
	rest = permutations(string[1:])
	result = set()
	for i in range(0, len(string)):
		for p in rest:
			result.add(p[0:i] + first + p[i:])
	return result


import itertools

def permutations(string):
	return set((''.join(x) for x in itertools.permutations(string, r=len(string))))


def permutations(s):
	if len(s) == 0:
		return []
	elif len(s) == 1:
		return [s]
	else:
		return set((s[i] + p for i in range(len(s)) for p in permutations(s[:i] + s[i + 1:])))


import itertools

def permutations(s):
	return list(set([''.join(x) for x in itertools.permutations(list(s))]))


def permutations(s):
	if len(s) == 1:
		return [s]
	result = []
	for (i, v) in enumerate(s):
		result += [v + p for p in permutations(s[:i] + s[i + 1:])]
	return list(set(result))


import itertools

def permutations(s):
	return list(set((''.join(p) for p in itertools.permutations(s))))


def permutations(string):
	from itertools import permutations
	a = [''.join(x) for x in permutations(string)]
	return list(set(a))


from itertools import permutations as pm
permutations = lambda s: map(''.join, set(pm(s)))


def permutations(word):
	if len(word) <= 1:
		return [word]
	perms = permutations(word[1:])
	char = word[0]
	result = []
	for perm in perms:
		for i in range(len(perm) + 1):
			result.append(perm[:i] + char + perm[i:])
	return set(result)