using System; using System.Collections.Generic; public class SentenceGenerator { public static List> ExpandSentences(List> partialSentences, List uniqueWords) { var newSentences = new List>(); foreach(var sentence in partialSentences) { foreach(var word in uniqueWords) { if(sentence.Contains(word)) { continue; } // Make a copy of the old sentence var newSentence = new List(sentence); // Add a new word newSentence.Add(word); newSentences.Add(newSentence); } } return newSentences; } public static void Main() { var uniqueWords = new List() { "hello", "beautiful", "world", "full", "of", "people" }; var sentences = new List>() { // Start with an empty sentence new List() }; for(int i = 1; i <= 3; i++) { sentences = ExpandSentences(sentences, uniqueWords); } System.Console.WriteLine("Generated " + sentences.Count + " sentences."); foreach(var sentence in sentences) { System.Console.WriteLine(string.Join(" ", sentence)); } } }