-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (40 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from itertools import permutations
def generateWord(letters, n):
return permutations(letters, n)
words_3_letters = generateWord(['o', 'b', 'b', 'a', 's'], 3)
words_4_letters = generateWord(['o', 'b', 'b', 'a', 's'], 4)
words_5_letters = generateWord(['o', 'b', 'b', 'a', 's'], 5)
def isWordCorrect(word):
f = open('./words/' + word[0] +'_words.txt', encoding="utf8")
while True:
line = f.readline()
if line != '':
line = line.replace(' ', '')
line = line.replace('\n', '')
line = line.split(',')
if word in line:
return True
else:
return False
def checkAllWords(letters_3, letters_4, letters_5):
correctWords = []
for word in letters_3:
str = ' '
str = str.join(word)
str = str.replace(' ','')
if isWordCorrect(str):
correctWords.append(str)
for word in letters_4:
str = ' '
str = str.join(word)
str = str.replace(' ','')
if isWordCorrect(str):
correctWords.append(str)
for word in letters_5:
str = ' '
str = str.join(word)
str = str.replace(' ','')
if isWordCorrect(str):
correctWords.append(str)
return correctWords
print(checkAllWords(words_3_letters, words_4_letters, words_5_letters))