main.cc now implements ordle.h
This commit is contained in:
parent
b542c22bc2
commit
64c47c753b
1 changed files with 43 additions and 1 deletions
44
main.cc
44
main.cc
|
@ -1,3 +1,45 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include "ordle.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { std::cout << "Hello, ordle!" << std::endl; }
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc < 2) {
|
||||||
|
std::cerr << "Usage: " << argv[0] << " <wordlist file>\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ifstream file(argv[1]);
|
||||||
|
if (!file) {
|
||||||
|
std::cerr << "Could not open file: " << argv[1] << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto candidates = read_candidates(file);
|
||||||
|
std::string wrong;
|
||||||
|
letters_and_indices green, yellow;
|
||||||
|
|
||||||
|
while (!candidates.empty()) {
|
||||||
|
std::cout << "Remaining candidates: \n";
|
||||||
|
for (const auto &word : candidates) {
|
||||||
|
std::cout << word << " ";
|
||||||
|
}
|
||||||
|
std::cout << "\n\n";
|
||||||
|
|
||||||
|
auto [new_wrong, new_green, new_yellow] = prompt();
|
||||||
|
wrong.append(new_wrong);
|
||||||
|
green.insert(new_green.begin(), new_green.end());
|
||||||
|
yellow.insert(new_yellow.begin(), new_yellow.end());
|
||||||
|
|
||||||
|
do_filter(candidates, wrong, green, yellow);
|
||||||
|
|
||||||
|
if (candidates.size() <= 1) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (candidates.empty()) {
|
||||||
|
std::cout << "No solution found.\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "Solution: " << candidates.front() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue