I am trying to write an executioner algorithm. My idea for this is as follows:
- Pre-process a dictionary that contains the relative frequencies of the letters of words depending on their length. The step is completed.
Example:
frequencyDict = {2: ['a', 'o', 'e', 'i', 'm', 'h', 'n', 'u', 's', 't', 'y', 'b', 'd', 'l', 'p', 'x', 'f', 'r', 'w', 'g', 'k', 'j'],
3: ['a', 'e', 'o', 'i', 't', 's', 'u', 'p', 'r', 'n', 'd', 'b', 'm', 'g', 'y', 'l', 'h', 'w', 'f', 'c', 'k', 'x', 'v', 'j', 'z', 'q'],
4: ['e', 'a', 's', 'o', 'i', 'l', 'r', 't', 'n', 'u', 'd', 'p', 'm', 'h', 'b', 'c', 'g', 'k', 'y', 'f', 'w', 'v', 'j', 'z', 'x', 'q'],
5: ['s', 'e', 'a', 'o', 'r', 'i', 'l', 't', 'n', 'd', 'u', 'c', 'p', 'y', 'm', 'h', 'g', 'b', 'k', 'f', 'w', 'v', 'z', 'x', 'j', 'q'],
6: ['e', 's', 'a', 'r', 'i', 'o', 'l', 'n', 't', 'd', 'u', 'c', 'p', 'm', 'g', 'h', 'b', 'y', 'f', 'k', 'w', 'v', 'z', 'x', 'j', 'q'],
7: ['e', 's', 'a', 'i', 'r', 'n', 'o', 't', 'l', 'd', 'u', 'c', 'g', 'p', 'm', 'h', 'b', 'y', 'f', 'k', 'w', 'v', 'z', 'x', 'j', 'q'],
8: ['e', 's', 'i', 'a', 'r', 'n', 'o', 't', 'l', 'd', 'c', 'u', 'g', 'p', 'm', 'h', 'b', 'y', 'f', 'k', 'w', 'v', 'z', 'x', 'q', 'j']}
I also have a word generator in the dictionary:
dictionary = word_reader('C:\\Python27\\dictionary.txt', len(letters))
Based on this feature
def word_reader(filename, L):
L2 = L+2
return (word.strip() for word in open(filename) \
if len(word) < L2 and len(word) > 2)
- This particular game will give you the latest vowel for free. For example, if the word was clay, the user will be presented with the following board: e ---- e- to guess. So, I want to find a way to create a new generator or list with all the words devoid of this, which do not match the pattern e ---- e-.
p = re.compile('^e\D\D\D\De\D$', re.IGNORECASE) will do this, but can find words that contain 'e in places other than the first letter and the second to the last letter.
So my first question is:
, "", ---- e-
, 6 , , "---- e-" . ?
NEW frequencyDict, ,
NewList.
:
cnt = Counter()
for words in dictionary:
for letters in words:
cnt[letters]+=1
?
newfrequencyDict , ,
. , () .
? ?