2024-12-14 14:02:21 +01:00
|
|
|
#include <iostream>
|
2024-12-14 14:14:19 +01:00
|
|
|
#include <fstream>
|
|
|
|
#include "ordle.h"
|
2024-12-14 14:02:21 +01:00
|
|
|
|
2024-12-14 14:14:19 +01:00
|
|
|
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);
|
2024-12-14 14:38:01 +01:00
|
|
|
std::cout << "File (" << argv[1] << ") loaded. " << candidates.size() << " candidates available.\n";
|
|
|
|
|
2024-12-14 14:14:19 +01:00
|
|
|
std::string wrong;
|
|
|
|
letters_and_indices green, yellow;
|
|
|
|
|
|
|
|
while (!candidates.empty()) {
|
|
|
|
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);
|
|
|
|
|
2024-12-14 14:44:34 +01:00
|
|
|
std::cout << "Remaining candidates: " << candidates.size() << "\n";
|
|
|
|
for (const auto &word : candidates) {
|
|
|
|
std::cout << word << " ";
|
|
|
|
}
|
|
|
|
std::cout << "\n\n";
|
|
|
|
|
2024-12-14 14:14:19 +01:00
|
|
|
if (candidates.size() <= 1) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (candidates.empty()) {
|
|
|
|
std::cout << "No solution found.\n";
|
|
|
|
} else {
|
|
|
|
std::cout << "Solution: " << candidates.front() << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2024-12-14 14:38:01 +01:00
|
|
|
}
|