Friday, February 17, 2017

Day 43

Current Challenge: No repeats please
Progress: Since my last update I was able to finish a few more "Advanced Algorithm Scripting" challenges. "Record Collection" was actually not that hard to crack. All it basically needed was proper 'if/else' structure. You can find my code on GitHub.

On the contrary, the  "Symmetric Difference" challenge was a bit tougher to get along. It took me some time to translate the logic into code but I eventually came up with a pretty neat and precise solution.

However, "Exact Change" was really challenging to get by. There were several problems literally popping out of nowhere and my browser hung up every now and then since I accidentally created an infinite loop somewhere in my code. That was really driving me mad!

System freezes
Codepen freezes

The trickiest part, tough, was to find a way to handle floating point numbers. I don't want to elaborate too much on it, but it can be frustrating at times. You just don't expect, say, 0.1 * 0.2 to be something like 0.020000000000000004 instead of just 0.02, but it has something to do with how a computer in general (not just JavaScript) processes numbers internally (binary instead of decimal representation). For a short introduction, I recommend you to watch the following video on YouTube. If you want to immerse yourself even more into the topic try Google. It's a well-known issue with lots of more or less detailed explanations.

Once you understand what's going on behind the curtain, there are several approaches you might want to use to circumvent the issue. Instead of floats, I decided to use integers for the internal computation of the function by simply multiplying all values with 100. To display a proper money format as output, you just have to divide each value by 100 again. It took me quite a while, but after some refactoring rounds, I managed to find a very clean approach to passing the provided tests. Check it out!

In turn, the "Inventory Update" was less troublesome again. You just have to stay focused because of the sometimes slightly confusing way of accessing multi-dimensional arrays.

To recap, the advanced algorithm challenges are definitively more difficult to get your head around so far but also more rewarding and satisfying once you found a viable solution at last.

If you have any questions or something in particular that troubles you, feel free to ask at any time by sending me a message or just leaving a comment below. :)

Thoughts: If I can maintain the current pace I might be able to obtain the Front End Certificate by the end of next month at the latest. That would be a first great milestone in my development. Wish me the best of luck!

My plans for the next days:
  • Work through the remaining "Advanced Algorithm Scripting" challenges
  • Finish chapter 9 on Regular Expression (including exercises; 'Eloquent JavaScript')
  • Gradually upload my work on GitHub

Follow me on GitHub

Follow me on FreeCodeCamp

Follow my Pens on Codepen

No comments:

Post a Comment