Gabriele Ferro Home

Intermediate Algorithm Scripting Challenges - Part. 1

Day 44: 15 September 2020

**Today’s Progress:**

I started the Intermediate Algorithm Scripting Challenges on freeCodeCamp !

Spent the rest of my free time reading articles and fixing this blog.

Sum all numbers in the given range

We create a variable to store the sum of every number in the given range.

Then we sort the array. This method will check every value in our array in sequence and it operates a swap between the values if needed.

Once the array is sorted, we calculate the total using the first number as starting index for our for cycle. The second number will be our loop condition. Particular attention to the = (equal sign) to avoid off-by-one errors.

Difference between two arrays

This caused me a bit of a headache just because I didn't remember studying the includes method at all (or I didn't knew before... I still can't find it in this blog nor my personal bloc-notes).

I found the answer thanks to a mixture of:

  1. google search about arrays methods
  2. Set Theory
  3. coffee

We exclude from the first set the elements that are not included in the second set.

We exclude from the second set the element that are not included in the first set.

We make the union of these two sets.


I cannot still believe that I am progressing so fast since the beginning of the #100DaysOfCode challenge.

**Link to tweet:**

[twitter-follow screen_name='20Gabriele20']

June 2024


Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.