private List <string> ParseWordToPieces(string word, WordChunksLengthCombination lengthCombination) { var startIdx = 0; var result = new List <string>(); foreach (var chunkLength in lengthCombination.ChunkLengths) { result.Add(word.Substring(startIdx, chunkLength)); startIdx += chunkLength; } return(result); }
private List <WordCombination> GetWordCombinationsByLengthCombination( Dictionary <int, HashSet <string> > wordChunksGroupedByLength, List <string> allWords, WordChunksLengthCombination lengthCombination) { var foundCombinations = new ConcurrentBag <WordCombination>(); allWords .ForEach(w => { var pieces = ParseWordToPieces(w, lengthCombination); if (ParsedPiecesFoundInChunks(pieces, wordChunksGroupedByLength)) { foundCombinations.Add(new WordCombination { WordChunks = pieces.Select(x => new WordChunk { Text = x }).ToList() }); } }); return(foundCombinations.ToList()); }