Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<string> GetWords(IEnumberable<char> characters) {
- char[] chars = characters.Distinct().ToArray();
- List<string> words = new List<string>(chars.Length*chars.Length);
- foreach (char i in chars)
- foreach (char j in chars)
- words.Add(i.ToString() + j.ToString());
- return words;
- }
- IDictionary<string, string> dictionary = GetRealTwoLetterWordDictionary();
- char[] availableChars = new char[] { 'a', 's', 't' };
- string[] combinations = GetAllCombinations(availableChars);
- IList<string> results = new List<string>();
- foreach (string combination in combinations)
- {
- if (dictionary.ContainsKey(combination)))
- {
- results.Add(combination);
- }
- string reversed = combination.Reverse();
- if (dictionary.ContainsKey(reversed)))
- {
- results.Add(reversed);
- }
- }
Add Comment
Please, Sign In to add comment