Skip to content

Commit 025b9a3

Browse files
authoredNov 28, 2022
Update Permutation and Combination cheatsheets. (trekhleb#963)
1 parent 5652560 commit 025b9a3

10 files changed

+25
-29
lines changed
 

‎src/algorithms/sets/combinations/README.md

+15-17
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ When the order doesn't matter, it is a **Combination**.
55
When the order **does** matter it is a **Permutation**.
66

77
**"My fruit salad is a combination of apples, grapes and bananas"**
8-
We don't care what order the fruits are in, they could also be
9-
"bananas, grapes and apples" or "grapes, apples and bananas",
8+
We don't care what order the fruits are in, they could also be
9+
"bananas, grapes and apples" or "grapes, apples and bananas",
1010
its the same fruit salad.
1111

1212
## Combinations without repetitions
1313

14-
This is how lotteries work. The numbers are drawn one at a
15-
time, and if we have the lucky numbers (no matter what order)
14+
This is how lotteries work. The numbers are drawn one at a
15+
time, and if we have the lucky numbers (no matter what order)
1616
we win!
1717

1818
No Repetition: such as lottery numbers `(2,14,15,27,30,33)`
@@ -30,12 +30,12 @@ It is often called "n choose r" (such as "16 choose 3"). And is also known as th
3030

3131
Repetition is Allowed: such as coins in your pocket `(5,5,5,10,10)`
3232

33-
Or let us say there are five flavours of ice cream:
33+
Or let us say there are five flavours of ice cream:
3434
`banana`, `chocolate`, `lemon`, `strawberry` and `vanilla`.
3535

3636
We can have three scoops. How many variations will there be?
3737

38-
Let's use letters for the flavours: `{b, c, l, s, v}`.
38+
Let's use letters for the flavours: `{b, c, l, s, v}`.
3939
Example selections include:
4040

4141
- `{c, c, c}` (3 scoops of chocolate)
@@ -46,23 +46,21 @@ Example selections include:
4646

4747
![Formula](https://www.mathsisfun.com/combinatorics/images/combinations-repeat.gif)
4848

49-
Where `n` is the number of things to choose from, and we
50-
choose `r` of them. Repetition allowed,
49+
Where `n` is the number of things to choose from, and we
50+
choose `r` of them. Repetition allowed,
5151
order doesn't matter.
5252

53-
## Cheat Sheets
53+
## Cheatsheet
5454

55-
Permutations cheat sheet
55+
![Permutations and Combinations Overview](./images/overview.png)
5656

57-
![Permutations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*JNK-n0Pt0Vbxk0lxVpgT5A.png)
57+
![Combinations overview](./images/combinations-overview.jpg)
5858

59-
Combinations cheat sheet
59+
| | |
60+
| --- | --- |
61+
|![Combinations with repetition](./images/combinations-with-repetitions.jpg) | ![Combinations without repetition](./images/combinations-without-repetitions.jpg) |
6062

61-
![Combinations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*7cFRn8jW4g_91YgDAbmxRQ.png)
62-
63-
Permutations/combinations algorithm ideas.
64-
65-
![Algorithms Idea](https://cdn-images-1.medium.com/max/2000/1*vLsSsZMnesCFPCYTYMbxrQ.png)
63+
*Made with [okso.app](https://okso.app)*
6664

6765
## References
6866

Loading
Loading
Loading
Loading

‎src/algorithms/sets/permutations/README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ When the order doesn't matter, it is a **Combination**.
44

55
When the order **does** matter it is a **Permutation**.
66

7-
**"The combination to the safe is 472"**. We do care about the order. `724` won't work, nor will `247`.
7+
**"The combination to the safe is 472"**. We do care about the order. `724` won't work, nor will `247`.
88
It has to be exactly `4-7-2`.
99

1010
## Permutations without repetitions
1111

12-
A permutation, also called an “arrangement number” or “order”, is a rearrangement of
13-
the elements of an ordered list `S` into a one-to-one correspondence with `S` itself.
12+
A permutation, also called an “arrangement number” or “order”, is a rearrangement of
13+
the elements of an ordered list `S` into a one-to-one correspondence with `S` itself.
1414

1515
Below are the permutations of string `ABC`.
1616

@@ -37,19 +37,17 @@ For example the the lock below: it could be `333`.
3737
n * n * n ... (r times) = n^r
3838
```
3939

40-
## Cheat Sheets
40+
## Cheatsheet
4141

42-
Permutations cheat sheet
42+
![Permutations and Combinations Overview](./images/overview.png)
4343

44-
![Permutations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*JNK-n0Pt0Vbxk0lxVpgT5A.png)
44+
![Permutations overview](./images/permutations-overview.jpeg)
4545

46-
Combinations cheat sheet
46+
| | |
47+
| --- | --- |
48+
|![Permutations with repetition](./images/permutations-with-repetitions.jpg) | ![Permutations without repetition](./images/permutations-without-repetitions.jpg) |
4749

48-
![Combinations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*7cFRn8jW4g_91YgDAbmxRQ.png)
49-
50-
Permutations/combinations algorithm ideas.
51-
52-
![Algorithms Idea](https://cdn-images-1.medium.com/max/2000/1*vLsSsZMnesCFPCYTYMbxrQ.png)
50+
*Made with [okso.app](https://okso.app)*
5351

5452
## References
5553

Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.