-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (43 loc) · 995 Bytes
/
main.cpp
File metadata and controls
45 lines (43 loc) · 995 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
void wordCheck(string eligible, string letterSet) {
int len = eligible.size();
string placeholder = eligible;
size_t found;
for (int j = 0; j < len; j++) {
found = letterSet.find(placeholder[j]);
if (found == string::npos) {
return;
}
else {
placeholder[j] = '*';
letterSet[found] = '#';
}
}
cout << eligible << endl;
return;
}
int main() {
cout << "Enter the 9 letters without spaces (key letter should be in the middle)" << endl;
string nineLetters;
cin >> nineLetters;
char key = nineLetters[4];
ifstream fullWordList("wordlist.txt");
vector<string> filteredList;
string word;
size_t keyFound;
while (fullWordList >> word) {
keyFound = word.find(key);
if (word.size() > 3 && word.size() < 10 && keyFound != string::npos) {
filteredList.push_back(word);
}
}
for (auto i: filteredList) {
wordCheck(i, nineLetters);
}
system("pause");
return 0;
}