Tag Archives: combinations

New Book: The Modern C# Challenge

My latest book, The Modern C# Challenge, is now available. It’s a collection of 100 programming challenges that let you test your ability in a wide variety of programming topics, many of which are not usually covered in traditional programming … Continue reading

Posted in algorithms, books, files, mathematics, puzzles | Tagged , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Generate words of a given length in C#

The example Generate three-letter words in C# uses three nested for loops to generate words that contain three letters. This example uses the following code to generate words of any given length. // Generate words with num_letters letters. private List … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , | 3 Comments

Generate three-letter words in C#

This example uses the following very simple code to generate three-letter words using the letters a through z. // Make the items. private void Form1_Load(object sender, EventArgs e) { List<string> values = new List<string>(); for (char ch1 = ‘a’; ch1 … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

Select N random items from an array in C#

This example builds a generic extension method that lets you easily select N random objects from an array. For example, it lets you select 5 items from an array holding 10 names. Picking one random item from an array is … Continue reading

Posted in algorithms, arrays, mathematics, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Generate all selections of K items from a set of N items in C#

This example is somewhat similar to Generate all of the permutations of a set of objects in C#. The basic idea is to use a recursive method to assign the next item to the combination. The first call to the … Continue reading

Posted in algorithms, combinatorics, mathematics | Tagged , , , , , , , , , , , , , , , | 3 Comments

Generate all of the permutations of a set of objects in C#

The basic idea is to use a recursive method to assign the next item in a permutation. The first call to the method assigns the permutation’s first item, the next call assigns the second item, and so forth. To assign … Continue reading

Posted in algorithms, combinatorics, mathematics, recursion | Tagged , , , , , , , , , , | 10 Comments