Is it worth solving problems on Codewars? Or how I fell in love with algorithms

Hello everyone! In this article I will tell you about learning algorithms, how I came to Codewars, and what I did wrong.

Note: codewars can be replaced with another resource, but I decide everything on codewars.

Let's start with some background information: I am a Frontend developer with about 4 years of experience, and during this time algorithms in their pure form have never been useful to me, well, almost, interviews are not counted. It turns out that we can close the discussion with the conclusion that algorithms are not needed for the frontend, and I cannot discuss more complex matters. Thank you for your attention……

Okay, it wasn't funny, but it was true, in fact, studying algorithms from books, videos and God knows what didn't help me at all, so I learned that there is such a way to make code faster, but I can't understand where and how to use it in my work. And at some point I started to think that it's just not my thing and I can stop trying, and hope that algorithms won't be useful any more.

Wait, let's figure out what an algorithm is, not in complicated language, but as simply as possible, it is a set of actions, the implementation of which will lead to the solution of a problem, it turns out I have used algorithms all my life, I just did not call it that. And how do we learn to do something most effectively? We just do it, then we look at how someone else did it, if his is more effective, we redo it according to the example, and then it becomes a habit, we ourselves do not notice that we are used to doing some things more effectively, simply because of our observation and experience.

Let's summarize the errors:

1) Hope that reading literature, watching videos, etc. will somehow help improve your skill

2) Lack of practice, even if I understood how to apply something, it was simply forgotten

3) The desire to see the result here and now

And how will codewars help with this? Well, if you go there once a week, solve one problem of the 8th category (the easiest ones), then there will be almost no result, but if you make it a habit to solve one problem a day, preferably of different levels of difficulty, and then look at several solutions from other authors, and try to understand why this solution is more effective, and then also redo the problem with new knowledge, and so you will have a small hobby, for 15-20 minutes a day, which in a couple of months will make you, genius of algorithms, correction, this habit will make your code a little more efficient, and will pump up your understanding of how to do it better and faster, you will better know the structures and capabilities of the language, I used more than half of the JavaScript methods for the first time precisely when solving problems on codewars. But there is one nuance that I must say, for a better understanding of what is happening in general, and how to understand which algorithm is better or worse, I advise you to read the book “Grokking Algorithms”, this will give you basic knowledge of algorithms, not the ability to use them, but an understanding of why to use them, and how algorithms are built. Reading the book will remove the glass ceiling under which you may find yourself. If you do not want to read the whole book, then read at least the first four chapters, this is about 80 pages.

And how is steel better in algorithms:

1) Read “Grokking Algorithms”

2) Solve one problem a day on Codewars

3) Increase the level of difficulty, personal recommendation, solve problems of 8-5 categories, more difficult problems lose a little connection with reality.

Well, here are some of my observations on how all of the above affects your career. You will get to know your programming language better, and learn to use more complex constructs that make your code faster and less cumbersome. Here is a small example:

Task: You will be given an array a and a value x. All you need to do is check if the given array contains a value. The array can contain numbers or strings. X can be either. Return true if the array contains a value and false if it does not.

First solution:

function check(a,x){
    for (let i=0; i < a.length; i++){
      if (a[i]==x){
        return true 
      }
    }
  return false
}

Second solution:

function check(a,x){
  return a.includes(x);
};

With this example I dug a small hole for myself, because algorithm experts can say that these are not algorithms at all, just a language method, where are the algorithms here? And to some extent they will be right, but our work is not connected with inventing super complex constructions, but is connected with finding the optimal solution, and algorithms should help us make the code simpler, clearer and faster, and not create complex constructions that hardly anyone will be able to understand.

There is not much to say about interviews, if you meet an interviewer who gives you a task of this type to solve, you will have an additional plus in the form of experience and confidence, but this is just one task

With this article I wanted to say that algorithms are not a super complex monster that is only subject to optimization and algorithm geniuses, but that anyone can master the basic level of algorithms, which is enough for most tasks, and this will only require a little patience and discipline.

Similar Posts

Leave a Reply

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