The Secret
Santa Problem

The definitive answer to the question: "how many combinations of secret santa pairs are there?"

So, how do you work this out?

We follow a relatively simple 3 step process.

1

Start with the pairs

First, you need to find out how many unique pairs there can be, by iterating through each participant and sub-iterating the remaining participants.

The below pairs would be output for the participants [a,b,c,d]:

[a,b]
[a,c]
[a,d]
[b,c]
[b,d]
[c,d]

This could also be derrived with the following formula:

2

Then the combinations

You will then need to run the list of unique pairs through an 'n choose k' combinational algorithm.

Some of the combinations will contain the same participant multiple times:

[[a,b],[a,c]]
[[a,b],[a,d]]
[[a,b],[b,c]]
[[a,b],[b,d]]
[[a,b],[c,d]]
[[a,c],[a,d]]
[[a,c],[b,c]]
[[a,c],[b,d]]
[[a,c],[c,d]]
[[a,d],[b,c]]
[[a,d],[b,d]]
[[a,d],[c,d]]
[[b,c],[b,d]]
[[b,c],[c,d]]
[[b,d],[c,d]]

3

Then filter the combinations

As there are combinations containing the same participant multiple times, you need to remove these by filtering the list.

You will then be left with a list of all unique combinations of unique pairs:

[[a,b],[c,d]]
[[a,c],[b,d]]
[[a,d],[b,c]]

If you want to know more about the n choose k combinational algorithm, please watch this video.

The answer!

Please try not to get too excited!

Participants

Add everyone who is taking part in secret santa.

I am afraid that at the moment we can only calculate the answer for 14 participants!
?
Unique Pairs
(Ignoring Known Couples)
?
Unique Combinations
(Ignoring Known Couples)

Unique Pairs

Unique Combinations

Sorry, we can only show 300 of the combinations...

Relationships complicate things...

Now we need to remove couples who don't want to be paired.

Singletons

Add singletons into the Coupletron 3000 to couplify them.

Coupletron 3000

True love. No question!

Look at the happy couple.

It takes two to tango...

Add a potential couple to initiate coupling process.

Known Couples

Once you have coupled everyone, go back to the answer page and re-calculate the answer.