-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpossibilityGenerator.py
76 lines (72 loc) · 2.81 KB
/
possibilityGenerator.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
word_list = []
with open("word_list/all_answers.txt", "r") as wordFile:
for wordAnswer in wordFile.readlines():
word_list.append(wordAnswer[:5])
is_in_word = []
is_in_position = {}
wrong_position = {}
not_in_word = []
curr_words = []
while len(is_in_position) < 5:
user_choice = input("Type your word: ")
user_choice_positions = input(f"Enter pos1-5 as 1-Grey 2-Yellow 3-Green, (eg-11231): ")
for posi, num in enumerate(user_choice_positions):
match num:
case "3":
if user_choice[posi] not in is_in_word:
is_in_word.append(user_choice[posi])
is_in_position[posi] = user_choice[posi]
if user_choice[posi] in not_in_word:
not_in_word.remove(user_choice[posi])
for posi, num in enumerate(user_choice_positions):
match num:
case "2":
if user_choice[posi] not in is_in_word:
is_in_word.append(user_choice[posi])
if user_choice[posi] in not_in_word:
not_in_word.remove(user_choice[posi])
wrong_position[posi] = user_choice[posi]
for posi, num in enumerate(user_choice_positions):
match num:
case "1":
if user_choice[posi] in is_in_word:
wrong_position[posi] = user_choice[posi]
elif user_choice[posi] not in not_in_word:
not_in_word.append(user_choice[posi])
for word in word_list:
if user_choice_positions == "11111":
curr_words.append(word)
elif user_choice == word and user_choice_positions != "33333":
if word in curr_words:
curr_words.remove(word)
else:
all_len = len(is_in_word)
all_in = 0
for letter in is_in_word:
if letter in word:
all_in += 1
if all_in == all_len:
if word not in curr_words:
curr_words.append(word)
for pos_in in is_in_position:
if word[pos_in] != is_in_position[pos_in]:
if word in curr_words:
curr_words.remove(word)
for pos_out in wrong_position:
if word[int(pos_out)] == wrong_position[pos_out]:
if word in curr_words:
curr_words.remove(word)
for not_in_letter in not_in_word:
if not_in_letter in word:
if word in curr_words:
curr_words.remove(word)
for allets in is_in_word:
if allets not in word:
if word in curr_words:
curr_words.remove(word)
word_list = curr_words
curr_words = []
if len(word_list) <= 1:
print(word_list)
break
print(word_list)