#include #include #include #include #include std::vector loadList() { std::ifstream inFile ("C:/reddit/listOfWords.txt"); std::string str; std::vector listOfWords; if (inFile.is_open()) { while (!inFile.eof()) { inFile >> str; listOfWords.push_back(str); } inFile.close(); } return listOfWords; } std::string decode(std::string msg, std::vector listOfWords) { for (int a = 0; a < listOfWords.size(); ++a) { std::string tempStr = listOfWords[a]; sort(tempStr.begin(), tempStr.end()); sort(msg.begin(), msg.end()); if (msg == tempStr) { return listOfWords[a]; } } } int main() { std::vector listOfWords = loadList(); std::string msg; std::cin >> msg; std::string decMsg = decode(msg, listOfWords); std::cout << "Decoded word: " << decMsg << "\n"; std::system("PAUSE"); return 0; }