- Pairing spores
- Fibonacci
Clone the repository, open your Visual Studio Code, and then execute the following command
npm start
- There is a list of spores that need to be paired. Given an array of integers representing the identifier of each spore type, determine how many pairs of spores with matching identifiers there are.
Example
sporeIds = [1, 2, 1, 2, 1, 3, 2]
- As shown in the picture, we have an input where we can introduce a number of spores separated by commas.
- In the picture, we can see that there is no pair number, which is why the number of pairs is
0
. - If we add one more number according to the solution, we can see that the number of pairs change to
1
- As we continue to add more numbers based on those already inserted, the count of pair numbers will increase.
- I present three distinct approaches for solving the Fibonacci sequence.
- The first two options involve the use of
loops
, while the third option employs arecursive function
. It is important to note that, when dealing with large numbers, I do not recommend the recursive function approach, as it may encounter stack-related issues.
- As depicted in the image, when the number
8
is inputted, each of the three different options (1, 2, and 3) should yield the same result, which is21
.