Exemplo n.º 1
0
def makeUnweird(word, dictionary):
    #perms = [word[0]+''.join(p)+word[-1] for p in itertools.permutations(word[1:-1]) if ''.join(p) != word[1:-1]]
    shuffledWords = getShuffled(word)
    if len(shuffledWords) < 1:	#if all permutations are equal to the original word, then no permutations are added and set is empty
      return word
    candidates = []
    for shuffledWord in shuffledWords:
      if shuffledWord in dictionary:
	candidates.append(shuffledWord)
    return '\\'.join(candidates)
Exemplo n.º 2
0
def makeWeird(word):
    if len(word) <= 3:
        return word
    # shuffled = [''.join(p) for p in itertools.permutations(text[1:-1]) if ''.join(p) != text[1:-1]]
    shuffledWords = getShuffled(word)
    if (
        len(shuffledWords) < 1
    ):  # if all permutations are equal to the original word, then no permutations are added and set is empty
        return word
    choice = random.choice(shuffledWords)
    return choice