Sort of an odd question- how would I go about generating a character string that doesn’t match any in a set of strings? I don’t want to make any assumptions about the strings. Solution is ideally STL based, but doesn’t have to be
Example:
vector<string> strings;
/*...*/
string unMatching = generateUnmatching(strings); //this is the function I want
assert(find(strings.begin(), strings.end(), unMatching) == strings.end());
One way is to use diagonalization:
Another method would be to copy the longest string in the set and append any character to the copy. This new string will be different from every string in the set.
There are all kinds of other ways to accomplish the same thing. Adding some constraints to the problem would help in selecting an algorithm that makes the most sense for your problem. For example, you might decide to generate the shortest string that doesn’t match any string in the set, or one with the lowest lexigraphic sort value, or one with the smallest number of characters in common with the other strings, or…