public PuzzleSolution SolvePuzzle(Puzzle puzzle) { List <string> properLengthWords = puzzle.WordLengths.Distinct().SelectMany(wl => _wordDictionary.GetWordsOfLength(wl)).ToList(); List <string> possibleWords = GetPossibleWords(properLengthWords, puzzle.Board); List <List <Word> > possibleGuesses = GeneratePossibleGuesses(possibleWords, puzzle.Board, puzzle.WordLengths); List <Word[]> solutions = possibleGuesses.Where(pg => pg.Count == puzzle.WordLengths.Count).DistinctBy(pg => string.Join(",", pg.Select(word => word.Letters))).Select(pg => pg.ToArray()).ToList(); return(new PuzzleSolution { Solutions = solutions }); }