diff --git a/src/algorithms/sets/combinations/README.md b/src/algorithms/sets/combinations/README.md index 30243b86..69fc0603 100644 --- a/src/algorithms/sets/combinations/README.md +++ b/src/algorithms/sets/combinations/README.md @@ -5,14 +5,14 @@ When the order doesn't matter, it is a **Combination**. When the order **does** matter it is a **Permutation**. **"My fruit salad is a combination of apples, grapes and bananas"** -We don't care what order the fruits are in, they could also be -"bananas, grapes and apples" or "grapes, apples and bananas", +We don't care what order the fruits are in, they could also be +"bananas, grapes and apples" or "grapes, apples and bananas", its the same fruit salad. ## Combinations without repetitions -This is how lotteries work. The numbers are drawn one at a -time, and if we have the lucky numbers (no matter what order) +This is how lotteries work. The numbers are drawn one at a +time, and if we have the lucky numbers (no matter what order) we win! 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 Repetition is Allowed: such as coins in your pocket `(5,5,5,10,10)` -Or let us say there are five flavours of ice cream: +Or let us say there are five flavours of ice cream: `banana`, `chocolate`, `lemon`, `strawberry` and `vanilla`. We can have three scoops. How many variations will there be? -Let's use letters for the flavours: `{b, c, l, s, v}`. +Let's use letters for the flavours: `{b, c, l, s, v}`. Example selections include: - `{c, c, c}` (3 scoops of chocolate) @@ -46,23 +46,21 @@ Example selections include: ![Formula](https://www.mathsisfun.com/combinatorics/images/combinations-repeat.gif) -Where `n` is the number of things to choose from, and we -choose `r` of them. Repetition allowed, +Where `n` is the number of things to choose from, and we +choose `r` of them. Repetition allowed, order doesn't matter. -## Cheat Sheets +## Cheatsheet -Permutations cheat sheet +![Permutations and Combinations Overview](./images/overview.png) -![Permutations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*JNK-n0Pt0Vbxk0lxVpgT5A.png) +![Combinations overview](./images/combinations-overview.jpg) -Combinations cheat sheet +| | | +| --- | --- | +|![Combinations with repetition](./images/combinations-with-repetitions.jpg) | ![Combinations without repetition](./images/combinations-without-repetitions.jpg) | -![Combinations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*7cFRn8jW4g_91YgDAbmxRQ.png) - -Permutations/combinations algorithm ideas. - -![Algorithms Idea](https://cdn-images-1.medium.com/max/2000/1*vLsSsZMnesCFPCYTYMbxrQ.png) +*Made with [okso.app](https://okso.app)* ## References diff --git a/src/algorithms/sets/combinations/images/combinations-overview.jpg b/src/algorithms/sets/combinations/images/combinations-overview.jpg new file mode 100644 index 00000000..9f544774 Binary files /dev/null and b/src/algorithms/sets/combinations/images/combinations-overview.jpg differ diff --git a/src/algorithms/sets/combinations/images/combinations-with-repetitions.jpg b/src/algorithms/sets/combinations/images/combinations-with-repetitions.jpg new file mode 100644 index 00000000..6a80a91c Binary files /dev/null and b/src/algorithms/sets/combinations/images/combinations-with-repetitions.jpg differ diff --git a/src/algorithms/sets/combinations/images/combinations-without-repetitions.jpg b/src/algorithms/sets/combinations/images/combinations-without-repetitions.jpg new file mode 100644 index 00000000..9262f99c Binary files /dev/null and b/src/algorithms/sets/combinations/images/combinations-without-repetitions.jpg differ diff --git a/src/algorithms/sets/combinations/images/overview.png b/src/algorithms/sets/combinations/images/overview.png new file mode 100644 index 00000000..fa8d6a66 Binary files /dev/null and b/src/algorithms/sets/combinations/images/overview.png differ diff --git a/src/algorithms/sets/permutations/README.md b/src/algorithms/sets/permutations/README.md index 8864af72..4b6a268a 100644 --- a/src/algorithms/sets/permutations/README.md +++ b/src/algorithms/sets/permutations/README.md @@ -4,13 +4,13 @@ When the order doesn't matter, it is a **Combination**. When the order **does** matter it is a **Permutation**. -**"The combination to the safe is 472"**. We do care about the order. `724` won't work, nor will `247`. +**"The combination to the safe is 472"**. We do care about the order. `724` won't work, nor will `247`. It has to be exactly `4-7-2`. ## Permutations without repetitions -A permutation, also called an “arrangement number” or “order”, is a rearrangement of -the elements of an ordered list `S` into a one-to-one correspondence with `S` itself. +A permutation, also called an “arrangement number” or “order”, is a rearrangement of +the elements of an ordered list `S` into a one-to-one correspondence with `S` itself. Below are the permutations of string `ABC`. @@ -37,19 +37,17 @@ For example the the lock below: it could be `333`. n * n * n ... (r times) = n^r ``` -## Cheat Sheets +## Cheatsheet -Permutations cheat sheet +![Permutations and Combinations Overview](./images/overview.png) -![Permutations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*JNK-n0Pt0Vbxk0lxVpgT5A.png) +![Permutations overview](./images/permutations-overview.jpeg) -Combinations cheat sheet +| | | +| --- | --- | +|![Permutations with repetition](./images/permutations-with-repetitions.jpg) | ![Permutations without repetition](./images/permutations-without-repetitions.jpg) | -![Combinations Cheat Sheet](https://cdn-images-1.medium.com/max/2000/1*7cFRn8jW4g_91YgDAbmxRQ.png) - -Permutations/combinations algorithm ideas. - -![Algorithms Idea](https://cdn-images-1.medium.com/max/2000/1*vLsSsZMnesCFPCYTYMbxrQ.png) +*Made with [okso.app](https://okso.app)* ## References diff --git a/src/algorithms/sets/permutations/images/overview.png b/src/algorithms/sets/permutations/images/overview.png new file mode 100644 index 00000000..fa8d6a66 Binary files /dev/null and b/src/algorithms/sets/permutations/images/overview.png differ diff --git a/src/algorithms/sets/permutations/images/permutations-overview.jpeg b/src/algorithms/sets/permutations/images/permutations-overview.jpeg new file mode 100644 index 00000000..0df355d2 Binary files /dev/null and b/src/algorithms/sets/permutations/images/permutations-overview.jpeg differ diff --git a/src/algorithms/sets/permutations/images/permutations-with-repetitions.jpg b/src/algorithms/sets/permutations/images/permutations-with-repetitions.jpg new file mode 100644 index 00000000..3e5c0a7c Binary files /dev/null and b/src/algorithms/sets/permutations/images/permutations-with-repetitions.jpg differ diff --git a/src/algorithms/sets/permutations/images/permutations-without-repetitions.jpg b/src/algorithms/sets/permutations/images/permutations-without-repetitions.jpg new file mode 100644 index 00000000..ca70b4d8 Binary files /dev/null and b/src/algorithms/sets/permutations/images/permutations-without-repetitions.jpg differ