Q:

How to boil a list down to least common strings?

I have a HashSet<string> which I'm loading vulgar words into for filtering purposes.  The problem is that my list will contain "Fu" and also the word spelled out completely.  What I want to do is filter the list down so it only contains "Fu", which would eliminate any other forms of the word from the list.  
In other words, I want to remove all strings in the list where its substring is also a list item.
How should I go about doing this?
I have the following where excludedWords is the original HashSet, but it's not working completely:
HashSet<string> copy = new HashSet<string>(exludedWords);

foreach (string w in copy)
{
    foreach (string s in copy)
    {
        if (w.Contains(s) && w.Length > s.Length)
        {
            result.Remove(w);
        }
    }
}

A:

You should compare every word in the set to every other (distinctly different) word in the set.  You can accomplish this as follows (although I'm sure this is not the most efficient method, by any means):
string[] strings = { "a", "aa", "aaa", "b", "bb", "bbb", "c", "cc", "ccc" };
List<string> results = new List<string>(strings);

foreach (string str1 in strings) {
  foreach (string str2 in strings) {
    if (str1 != str2) {
      if (str2.Contains(str1)) {
        results.Remove(str2);
      }
    }
  }
}

return results;

