Week 13: Attack Of The Algorithms!

Hand punching thru algorithm

I waited twelve long weeks to start working on algorithms only to realize that I had already been working on them for quite some time.

When you are a new self-taught programmer, algorithm is a word steeped in mystery and awe. It is a word that comes up frequently when you research programming, usually in the context of some incredibly difficult interview question asked by the likes of Google or Microsoft.

If the internet is to be believed, Computer Science students spend four entire years learning nothing but algorithms!

It is also common to see tweets about algorithms. These usually come in one of two forms. Either the person is stuck and bemoaning the difficulty of the algorithm or someone is offering a solution to an algorithm that, to a new programmer, looks like something found on an alien spaceship.

Example algorithm solution.

What is an Algorithm?

Boiled down to the simplest definition, an algorithm is nothing more than the solution to a problem. Yes, these problems can be incredibly complex and difficult but it doesn’t mean algorithms should be feared.

In fact, like I mentioned earlier, we are often working with algorithms before we even realize it.

Anytime you work on a lesson in which you are tasked with finding a solution to a problem, you are in effect coming up with an algorithm. I first started to encounter it with JavaScript, but I am sure it happens in other first languages as well.

When you working on a lesson you have the advantage of knowing that the solution is tied to what you are learning. For example, if you are working on For Loops, it is safe to assume that the solution to the problem involves using a For Loop.

Once you start working on more freestanding algorithms, you won’t have the context of a lesson to point you in the right direction. You will have to first analyze the problem and then come up with a solution.

Solving Algorithms

This is both challenging and rewarding as I learned last week when I started working on the Basic Algorithms at freeCodeCamp.

The beauty of these problems is that they typically require you to apply multiple concepts. Instead of just a For Loop, you might also have to combine it with two or three functions as well.

The answer teases you because you think, “I know how to do this, I know how to do that, and I know how to do the other thing, but how do I do all three at the same time?”

Figuring all that out can be time-consuming but it sure does feel good once you do.

freeCodeCamp Basic Algorithm Challenge #1

I am about halfway through fCC’s Basic Algorithm Challenges but you can find all my solutions either at CodePen or GitHub.

In hindsight, I wish I would have blogged about each algorithm as I solved it. I may try to go back and do it sometime soon while the ideas are still relatively fresh in my mind but there is only so much time. The more time I spend blogging, the less time I spend learning, so it is always a difficult balance.

To say algorithms dominated my week would be an understatement. I have been thinking about algorithms so much that I have even started dreaming about them. Sadly, I usually dream about the solutions that don’t work instead of the ones that do. I guess that means I need to work harder or eat fewer spicy foods.

Flexbox

Besides working on algorithms, I also started digging into Flexbox last week.

I was immediately impressed and my number one question was, “Why don’t we just use Flexbox for everything?”

I later learned that the reason is that many older browsers aren’t compatible with Flexbox. Fortunately, that becomes less of an issue every day.

I can’t wait to go back an use Flexbox to redesign some of the projects I have worked on.

Until next time, Happy Holidays and thanks for reading!

Sharing is caring!

Author: Lee

Hi, my name is Lee and I am a 40-something who recently made the decision to become a self-taught programmer. This site was set up to chronicle that journey and my experiences along the way. Feel free to contact me with any comments, questions, or suggestions.

Leave a Reply

Your email address will not be published. Required fields are marked *

fifteen + 1 =