Created by John Robison
Creating a subset from a collection where the order of selection does not matter.
This is also known as the Binomial Coefficient.
\[ {n\choose k} = \frac{n!}{k!(n - k)!} \]
While playing poker, you wonder how many possible hands you could possibly be dealt. You know that a standard deck contains 52 cards and your hand holds 5 cards. Each card is distinct and your hand can be rearranged, so the order is unimportant.
\[ {52\choose 5} = \frac{52!}{5!(52 - 5)!} \]
Plugging this into your favorite calculator or REPL shows that there are 2,598,960 possible hands
Creating a subset from a collection where the order of selection does matter.
\[ _{n}P_{k} = \frac{n!}{(n - k)!} \]
Buff, being the studmuffin he is, has many adoring fans. One such fan wants to make a shrine to Buff with a 3 picture frame using photos from their Buff folder containing 200 pictures. How many ways can these pictures be placed in this picture frame?
\[ _{200}P_{3} = \frac{200!}{(200 - 3)!} \]
Plugging this into your favorite calculator or REPL shows that there are 7,880,400 possible ways to worship everyone's favorite boy
Really obscure number sets that always seem to creep up in competitons as the 'easy' solution to a problem.
\[ C_{n} = \frac{1}{n + 1} {2n\choose n} = \frac{(2n)!}{(n + 1)!n!} = \prod_{k = 2}^n\frac{n + k}{k} for \ n \ge 0 \]
1
1
2
5
14
42
132
429
1430
4862
16798
...
The people who make the problems said so.
A Dyck Word is a string consisting of n X's and n Y's such that no initial segment of the string has more Y's than X's. The count of the Dyck words for a string of length 2n is Cn.
XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY.
In a system where there are n balls and m buckets, this problem consists of determining the load (i.e. how many balls are in a given bucket).
\[ Maximum\ Load = \frac{log\ n}{log\ log\ n} (1 + o(1)) \]
Or how Python is once again the superior language.
itertools.combinations("ABCDEFG", 3)
itertools.combinations_with_replacement("ABCDEFG", 3)
itertools.permutations("ABCDEFG", 3)
itertools.count(10, 2)
itertools.cycle("ABCD")
itertools.repeat(10, 3)