Thursday, February 9, 2017

Day 35

Current Challenge: Finders Keepers
Progress: I put the "Weather App" on hold for the moment to not lose traction solving algorithms. It worked pretty well until I ran into the "Smallest Common Multiple" challenge. Boy, this was a bummer! 

Confused baby

I haven't been stuck like that ever before. Took me 2 days* to figure it out. I was confused by the sheer amount of different algorithms and techniques you can apply ...

My first approach was so inefficient, that the largest range my machine was able to compute was from 1-8 (i.e. 'smallestCommons([1, 8]')). That actually doesn't come as a surprise, if you go through the code to get a sense of what it does. It basically creates an array for each number in the range with all the multiples up to the greatest common multiple in it, to be able to compare all the multiples of each number and search for the least common multiple. As a result, the arrays got way too bloated for larger numbers (e.g. if you have a range of 1-13 that's actually (13! / 2) indices only for the array of multiples of two's). Well, guess I took the provided "helpful link" in the task's description too literal. ;) Fell free to have a look at it. I commented it out but it's still below my current solution on FCC.

Anyway, after quite some time and with the help of various sources I managed to solve the task. Admittedly, it's not entirely my own code. But since it became more and more frustrating, I decided to work with some snippets I found on StackOverflow and adapted them to fit my needs. The thing I grappled most with, was to get my head around recursive programming style. I read about it a while ago but didn't use it much so far, since there was no real need for it. I think it's important to get acquainted with recursion early on (well, not too early obviously), but one thing is really crucial: don't get obsessed with building an algorithm entirely from scratch. This can't be stressed enough, especially if you, like me, belong to the species who's deeply dissatisfied by not fully knowing. That's probably the flipside of curiosity. But as an aspiring web developer, I personally think our focus should be on implementation and not reinventing the wheel (I mean it's definitely fun to stretch your mind but it might distract you from actual coding because a lot of more or less complex math might be involved). If you have a different opinion on that, I'd love to hear it. Please leave a comment below!

My focus for the next days is to get through the rest of the intermediate algorithm challenges, as smoothly as possible. Depending on the difficulty level of the next few exercises I might take (or more precisely "have to take") a quick detour, though.

*Note: 1 day of programming actually means from around 8 am until noon (my daily programming routine).
Thoughts: I noticed that solving algorithms is quite a lot about math. With that said, I decided to also devote some time to brush up my somewhat rusty math skills on Khan Academy (at least half an hour a day). I'm impressed how sophisticated their platform has become.

Whew, that was quite an update but I had a lot on my mind I wanted to share. If you have any questions or suggestions, don't hesitate to leave a comment or to get in touch with me.

Simpsons comic guy in front of a computer

As I already mentioned before, you can expect an update coming at least once a week. So stay tuned! :)

Update: Unfortunately I haven't received a word from the learning community I told you about last time yet. Still hoping to get in on one of the upcoming cohorts.

Check it out, maybe it's something for you as well:

My plans for the next days:
  • Work through the remaining "Intermediate Algorithm Scripting" challenges

Follow my Pens on Codepen
Follow me on FreeCodeCamp

No comments:

Post a Comment