-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
47 lines (37 loc) · 1.18 KB
/
main.cpp
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
#include "wordle-solver.h"
int main(int argc, const char** argv) {
if (argc != 2) {
usage();
return 0;
}
std::ifstream word_file(argv[1]);
if (!word_file.is_open()) {
std::cout << "File not found/invalid. Please place word list file in the same directory as solver.\n";
usage();
return 0;
}
std::string word, guess, result;
std::vector<std::string> words;
while (word_file >> word) {
words.push_back(word);
}
std::cout << "Enter guess: ";
std::cin >> guess;
while (true) {
std::cout << "Enter result string: ";
std::cin >> result;
prune_word_list(guess, result, words);
std::cout << "Words remaining: " << words.size() << '\n';
if (words.size() == 1) {
std::cout << "Found solution: " << words[0] << std::endl;
return 0;
} else if (words.size() < 1) {
std::cout << "You probably entered something wrongly. Exiting." << std::endl;
return 0;
}
word = find_max_entropy(words);
std::cout << "Try: " << word << '\n';
guess = word;
}
return 0;
}