Sha256: 3a98adb7e9c29b4cb2690292991858f2f60b788411ce56ab493ca1a7936718b0
Contents?: true
Size: 762 Bytes
Versions: 396
Compression:
Stored size: 762 Bytes
Contents
#include "anagram.h" #include <boost/algorithm/string/case_conv.hpp> #include <algorithm> #include <cctype> using namespace std; namespace { string make_key(std::string const& s) { string key{boost::to_lower_copy(s)}; sort(key.begin(), key.end()); return key; } } namespace anagram { anagram::anagram(string const& subject) : subject_(subject), key_(make_key(subject)) { } vector<string> anagram::matches(vector<string> const& matches) { vector<string> result; for (string const& s : matches) { if (s.length() == key_.length() && boost::to_lower_copy(s) != boost::to_lower_copy(subject_) && make_key(s) == key_) { result.push_back(s); } } return result; } }
Version data entries
396 entries across 396 versions & 1 rubygems