diff --git a/lab2/dictionary.cc b/lab2/dictionary.cc index feaf66d..7bfd397 100644 --- a/lab2/dictionary.cc +++ b/lab2/dictionary.cc @@ -83,14 +83,16 @@ void Dictionary::trim_suggestions(std::vector &suggestions, suggestions.erase(std::remove(suggestions.begin(), suggestions.end(), word), suggestions.end()); - // Example: Remove any suggestions that are too short - suggestions.erase( - std::remove_if(suggestions.begin(), suggestions.end(), - [](const std::string &s) { - return s.length() < - 3; // Remove words shorter than 3 characters - }), - suggestions.end()); + auto l = word.length(); + std::cout << "WTF" << l << std::endl; + + // Example: Remove any suggestions that are not within 1 string length + suggestions.erase(std::remove_if(suggestions.begin(), suggestions.end(), + [l](const std::string &s) { + return s.length() > (l + 1) || + s.length() < (l - 1); + }), + suggestions.end()); } int Dictionary::spit(path p) {