Recursion

JavaScript Recursion Exercise

Koowoy
Flatten Create a function that flattens all nested arrays in the given array. My initial instinct was to use the JavaScript function .flat() and recursion. However, a problem occurred with the base case. In order for recursion to function correctly, the base case needs to be set to determine if the recursion should stop. In my above solution, I wanted to compare the array before and after flattening it.

[Sidenote/JS] Using Recursion to Get All Possible Combinations

Koowoy
The definition of combination in mathematics is as follows: In mathematics, a combination is a selection of items from a collection, such that the order of selection does not matter. (from Wikipedia) In order to get all the possible selections, the following formula is used: image-source The first part refers to all the combination that includes a certain value, and the latter part refers to all the combinations that does not include that value.

Enlightenment of the Day 21.02.01

Koowoy
Sorting and Locking Pairs for Tideman (CS50 Problem Set 3) The Original Problem Explained (Tideman) The Problem Encountered Although with the test sets provided with the example seemed to work just fine with the code I originally wrote, when graded, it showed that my code didn’t lock the pairs correctly (meaning it didn’t lock what it was supposed to, and locked pairs where it should have skipped). 1. Sorting Problem Instructions