Combinatorics is fascinating. It's about counting. The concept and exercises are often simple to understand, but the solutions can be tricky to find. Does order matter? Are repetitions allowed?
I wanted to write a short summary for myself where I could find the main formulas and have an intuitive proof of why they work. The proofs may not be extremely rigorous, but I think they are fairly easy to understand.
In these explanations, you will mainly encounter 2 letters, (the total number of elements in the set) and (the length of the sequence you want to get). For example, if you have an alphabet with 4 letters and you want to form a 2-letter password, then and .
With Order, Repetition Allowed
Example: How many unique 6-letter passwords can you create? (assuming that the allowed characters are A-Za-z0-9 for a total of 62 chars) → .
Formula:
Proof: We fill the positions one by one. Each position have possible elements because repetition is allowed. By the multiplication rule, the total number of sequences we can form is:
With Order, No Repetition
Example: How many ways can the top 3 finishers be arranged from 10 runners? → .
Formula:
This is called a -permutation.
The number of -permutations is hence .
Proof: We fill the positions one by one. We have possible elements for the first position, for the second position (since repetition is not allowed and one element has been used)... and for the th element, there are choices. By the multiplication rule, the total number of sequences we can form is:
Without Order, Repetition Allowed
Example: How many ways to choose 3 scoops of ice cream from 5 flavors (flavors can repeat)? → .
Proof: TODO, this one is harder. Try it on your own, I will publish it later.
Without Order, No Repetition
Example: How many 5-card hands can be drawn from a 52-card deck? → .
Proof: Let's define . Each -permutation of arises only once as a result of these steps, done one after the other:
- Take elements inside (no repetition, no order, like drawing balls from a bag containing balls numbered from to ). By definition this is .
- Order these elements. There are ways of ordering them (see -permutation proof above).
By the multiplication rule,
If you are interested and want to know more, a good reference is Introductory Combinatorics by Richard A. Brualdi.
Unrelated "promotion" PS: If you’d like to support my work and build web apps quickly without tedious setup, consider buying my template 1Server 😉.