Given a hash of letters and the number of times they occur, recreate all of the possible anagram combinations that could be created using all of the letters, sorted alphabetically.

The inputs will never include numbers, spaces or any special characters, only lowercase letters a-z.

E.g. get_words({2=>["a"], 1=>["b", "c"]}) => ["aabc", "aacb", "abac", "abca", "acab", "acba", "baac", "baca", "bcaa", "caab", "caba", "cbaa"]

Difficulty: introductory

Starter code:

def get_words(hash_of_letters):
	

Solutions:
from itertools import permutations

def get_words(letters):
    word = "".join(qty * char for qty in letters for chars in letters[qty] for char in chars)
    return sorted({"".join(permutation) for permutation in permutations(word)})

from itertools import permutations


def get_words(hash_of_letters):
    letters = "".join(cnt * c for cnt, cs in hash_of_letters.items() for c in cs)
    return sorted({"".join(xs) for xs in permutations(letters)})

from itertools import permutations
def get_words(hash_of_letters):
    string = ''
    for i in hash_of_letters:
        string += ''.join(hash_of_letters[i] * i)
    answer = set(permutations(string))
    answer = sorted(answer)
    for i in range(len(answer)):
        answer[i] = ''.join(answer[i])
    return answer

from itertools import permutations

def get_words(hash):
    chars = ''
    for k,v in list(hash.items()): chars += ''.join(v)*k
    return sorted(set(''.join(p) for p in permutations(chars)))


from itertools import permutations

def get_words(dct):
    s = ''.join(c*n for n,lst in dct.items() for c in lst)
    return sorted( set(map(''.join, permutations(s, len(s)) )) )

def get_words(letter_counts):
  from itertools import permutations
  
  word = ''.join(count*char for count, chars in letter_counts.items() for char in chars)
  
  return sorted(set(map(lambda x: ''.join(x), permutations(word))))

def get_words(d):
    #your code here
    from itertools import permutations
    s = ''
    for key in d:
        for char in d[key]:
            s+=char*key
    p = permutations(s, len(s))
    return sorted(list(set([''.join(word) for word in p])))

from itertools import permutations;get_words=lambda d:sorted(["".join(i) for i in set(list(permutations("".join(["".join([k * i for k in j]) for i, j in d.items()]))))])

from itertools import permutations
def get_words(h):
    return [''.join(p) for p in sorted(set(permutations(''.join([letter * key for key in h for letter in h[key]]))))]