My Code
from itertools import permutations
original = str(input('What word would you like to unscramble?: '))
gen = []
for bob in permutations(original):
gen.append(''.join(bob))
inputFile = open('dic.txt', 'r')
compare = inputFile.read().split('\n')
inputFile.close()
rondo = set(john for john in gen if john in compare)
for magic in rondo:
print(magic)
I use it to unscramble words by finding all possible permutations of a word and comparing each permutation to a dictionary to find real words, and then returning those real words. However, going over eight letters causes an error as I run out of ram before the program can finish and words with seven or eight letters take a long time to unscramble. I would like to know if there is a way to make my code able to run faster with longer words as well as a way to increase the maximum word length. I'm using Python 3 and am a bit of a beginner if it matters.