So I am currently working on Beginner algorithm JS challenges and while I’ve done half of them in a breeze, my default solution is always the basic solution. Once I have finished the challenges, I open the link to answers to check up on the advanced and intermediate solutions and sometimes I have trouble understanding them or even if I do, it is very unlikely for me to actually write those solutions as my default way of writing code. Is it just me or does every beginner experience this? Should I be practicing more into writing compact code? Any help on this matter would be appreciated, thank you so much!
I’m not sure if it’s every beginner, but I have certainly been having the same problem. I feel like most of the more advanced solutions also don’t have explanations that are as detailed.
Take one step at a time.
I felt the same when I was beginning as well and looks like you are heading in the right direction. The most important part is being able to solve algorithms then comes in code optimizations and refactoring, which will take time. Keep diving at it and once you feel like you got the hang of it and intuitively solve it then look at advanced solutions how to make your code better.
I agree! Most of them leave me confused haha.
Thanks a lot! Really appreciate your advice. Good to know that this is normal!
Sometimes the solutions that are included and labeled as “advanced” are considered to be so because they use methods that you haven’t been introduced to if you are doing the curriculum in order and haven’t learned them from another source.
readable code > compact code
No use writing compact code if you or no one else understands it. Good code flows like sentences in a paragraph. Before you can use more complex words you gotta understand the basics of how to write a readable sentence. As your writing gets better you can use new words to help you express your thoughts with fewer words and more detail.
Thats because they are advanced solutions, and you are just now learning and working your way through the beginner challenges. You are definitely not expected, nor should you put pressure on yourself to understand the advanced way to do something you are just now starting to learn.
Once youve completed the beginner, intermediate advanced challenges, you can go back to the beginning to challenge yourself to write more efficient code, and at that time, you will have learned enough to understand the higher level solutions.
Wanted to add…that doesnt mean you shouldnt look at these solutions. Once you have figured out your solution, first congratulate yourself (just getting the challenge to pass is something to be proud of) and then look at the solutions to expose yourself to other methods. So now, even if you dont totally understand them, at least you know another way exists…this exposure will help you as you go along.
I have done all the algorithm challenges twice now, and the advanced solutions made more sense to me the second time around. They helped me to re-factor my own solutions to produce tighter code. Give yourself time to absorb this stuff. It’s all brain food.
I think it is wonderful that you are looking at the intermediate and advanced solutions AT ALL. A few coders I know (myself included) find a lot of value in reviewing other coding solutions after completing their own working solution for ideas on how it can be improved.
At first, I had enormous trouble understanding advanced or ‘best practice’ solutions on code wars. For example, I didn’t know how to use regular expressions, or certain built in functions like replace, or the ternary operator. This is completely normal. Personally what worked for me is to continue practicing, but also look at the alternative solutions. If you find them to be interesting or neat in some way but do not understand some of it, you can begin to google the techniques used in the solution, then try writing the new solution from scratch.
This is how I learned ternary, as well as some built in functions, and even alternative logic that is more efficient, etc. After a while of doing this, you’ll find that you begin to write your solution only to find your solution is fairly similar to intermediate or advanced solutions, or even unique, yet just as good!
I would not be discouraged, and continue to review the solutions after completing your own and attempt them if you feel its a good challenge without going too far above your understanding level. IMO this is a FANTASTIC way to improve your coding skills!
Consider taking a community college course on Logic. It seems to the most relevant skill from law school and philosophy class that transferred to development.
I’m sure I will get berated for saying this but…
I had the exact same problem. You know what I did… I searched for the solutions on youtube. I watched the video, read the related articles on wiki, and read how to use every built in function they utilized, went back and tried to emulate the solution.
When I got stuck I repeated the process until I understood every aspect of the solution. Guess what? It works. Not only was I able to write the solution, but it expanded my knowledge immensely. You can’t understand some of these more difficult problems, because you haven’t been tortured in them. They are based on high level mathematical equations and the knowledge of built in functions.
There’s no shame in watching tutorials. There is no difference in it and paying for a degree and having an instructor walk you through these difficult tasks.
Good to hear that. Thanks