This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input_file = open('wordsEn.txt') #read the english word list from file | |
data = [] | |
for line in input_file: | |
line = line.rstrip('\n') #ignore the '\n' in the file | |
line = line.rstrip('\r') | |
if len(line)>=5 and len(line)<=7: | |
#print line | |
data.append(line) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letterSortByFrequency = "etaoinsrhdlucmfywgpbvkxqjz" | |
primeNumber = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] | |
letterToPrime = {} | |
for i in range(len(primeNumber)): # Create a map form letter to prime number, based on the frquency of each letter appear in english word | |
letterToPrime[letterSortByFrequency[i]] = primeNumber[i] | |
correctWord = {} | |
input_file = open('wordsEn.txt') #read the english word list from file | |
for line in input_file: | |
line = line.rstrip('\n') #ignore the '\n' in the file |