# Category Archives: combinatorics

## Create a schedule for a round robin tournament with home teams in C#

My book Essential Algorithms, Second Edition describes an algorithm for creating a round robin schedule in detail. The following posts also explain how you can create a round robin schedule in slightly less detail. Generate a schedule for a round … Continue reading

Posted in algorithms, combinatorics, mathematics | | Comments Off on Create a schedule for a round robin tournament with home teams in C#

## Review posted: “The Modern C# Challenge”

The Modern C# Challenge: Become an expert C# programmer by solving interesting programming problems Clock End Gooner has posted a review of my latest book, The Modern C# Challenge: Become an expert C# programmer by solving interesting programming problems. Please … Continue reading

Posted in books, combinatorics, cryptography, geometry, mathematics | Comments Off on Review posted: “The Modern C# Challenge”

## Find two sets where the median of one is the mean of the other and vice versa in C#

For an upcoming book, I wanted to find sets where the mean (average) of one is the median (middle value) of the other and vice versa. I wanted to avoid trivial examples such as {1, 1, 1} and where the … Continue reading

Posted in algorithms, combinatorics | | Comments Off on Find two sets where the median of one is the mean of the other and vice versa in C#

## Display team names for a round robin tournament in C#

The example Generate a schedule for a round robin tournament in C# explains how you can generate a schedule for a round robin tournament. This example simply adds the ability to display the schedule using the team names instead of … Continue reading

Posted in algorithms, combinatorics, mathematics | | Comments Off on Display team names for a round robin tournament in C#

## Linkback to the Secret Santa Problem

Tom left a comment to my post Calculate the number of secret Santa permutations in C#. He used that example to build a site in JavaScript explaining how the algorithm works. It’s a pretty cool little page. Drop by and … Continue reading

Posted in algorithms, combinatorics, mathematics | | Comments Off on Linkback to the Secret Santa Problem

## Generate a schedule for a round robin tournament in C#

Click here to see a description of the algorithm the program uses to schedule a round robin tournament. Function GenerateRoundRobinOdd returns an array where results[i, j] gives the opponent of team i in round j of the round robin tournament. … Continue reading

## Enumerate pairs of objects in arrays or IEnumerables in C#

Sometimes it’s useful to enumerate pairs of objects in an array or enumerable. For example, if you have an array holding volleyball teams, the pairs would list each of the possible matches you could make. If the teams are A, … Continue reading

Posted in arrays, combinatorics, extension methods | | Comments Off on Enumerate pairs of objects in arrays or IEnumerables in C#

## Send secret Santa emails in C#

This example shows how you can automatically send secret Santa emails for a party. The example Pick a secret Santa assignment in C# shows how you can quickly make secret Santa assignments. The post Calculate the number of secret Santa … Continue reading

Posted in algorithms, combinatorics, mathematics | | Comments Off on Send secret Santa emails in C#

## Calculate the number of secret Santa permutations in C#

The example Pick a secret Santa assignment in C# picks a valid permutation of the people so no one is mapped to himself or herself. Such a permutation is called a derangement. See that example for details. The number of … Continue reading

## Pick a secret Santa assignment in C#

In a secret Santa party, you put everyone’s names in a hat and people draw from the hat. Each person becomes the secret Santa for the person he draws and gets that person a present for the party. To keep … Continue reading