pszczyg

Untitled

Aug 4th, 2016
760
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public IEnumerable<string> FindObj()
  2.         {
  3.             var wordsFromFile = File.ReadAllLines(_dictionaryPath);
  4.             var allWordsWithTheLetters = new List<string>();
  5.             foreach (var word in wordsFromFile)
  6.             {
  7.                 if (word.All(_allowedChars.Contains))
  8.                     allWordsWithTheLetters.Add(word);
  9.             }
  10.  
  11.             var longestWords = new List<string>();
  12.             foreach (var word in allWordsWithTheLetters.OrderByDescending(x=>x.Length))
  13.             {
  14.                 if(longestWords.LastOrDefault() == null || longestWords.Last().Length <= word.Length)
  15.                     longestWords.Add(word);
  16.             }
  17.  
  18.             return longestWords;
  19.         }
RAW Paste Data