I would like to solve the basic algorithm challenges without looking up the answer to the code. This seems impossible, however, because I don’t even know the methods that are supposed to be used to perform a task. For example, in the challenge where I need to reverse a string, freecodecamp does not even tell me that I have to use the methods str.split, arr.reverse, and arr.join. How the heck can I implement a solution if I don’t even have the tools to do so.
They will be hard, you can’t get around this because at some point you have to stop having your hand held and actually figure out how to solve problems with code, that’s the entire point of this.
You do have the tools to do it, you’ve been given them. You’re just not using them.
You don’t, that just happens to be one possible solution. So for example
- look in the documentation to see if there is a function for strings that would reverse a string.
- there isn’t, so you’re going to have to do it manually.
- what is a string? Its a series of characters one after the other.
- you have learned how to use loops.
- you have learned how to join strings together.
- you have learned how to loop through strings
- so why not loop through the string from the end to the start? That’ll give you the characters one by one in reverse order, and you know how to join them together.
There are many other ways to do this.
This is how this works. You break a problem down into tiny manageable chunks of things you know how to do, and then you do those things. Rinse and repeat. Of course it is hard: self-directed learning in particular is extremely difficult, but you have resources you can use – these forums exist to help you, for example. And you need to learn to read and use the documention, to look to see if there is built-in functionality you can maybe use for a given problem (again, yes, this is difficult because you don’t know the questions you need to ask Google/etc to get good answers at first)
And if you are completely stuck, do look for a possible solution, this isn’t an exam. But make sure you understand how that solution works: implement it yourself. It’s not a box-ticking exercise, and I’ll reiterate that for all of those challenges there is no one single correct answer. If you’ve looked up the solution, learn from it. Next time you face some similar problem you will know one way to approach it, and you’ll also know what kind of questions to ask if you get stuck.
Algorithms are not easy. You will come to learn that any programming language, they are almost the hardest one to overcome. The purpose of these lessons are to challenge you. You are trying to get a certificate after all.
At this point of the curriculum it is assumed that you have passed the previous challenges and have thus passed the phase of ‘absolute beginner’. Try taking a break from it and learning elsewhere and then coming back to them with a new perspective. This is challenging by design.
If you end up going to a paid boot camp, even they won’t be able to hold your hand at writing algorithms. It is something you are going to wrap your brain around because it’s logic that must make sense to you. It’s actually the coolest part about programming, because there are no right or wrong answers if the function returns the correct value in the end.
Don’t let this get your down, just take a break from this part of programming and build something with what you already know. There is no rush to getting their certificate, it’s just a piece of paper after all. There are resources for learning algorithms out there too if you really want to continue with this.
This reply is extremely helpful. To summarize what you are saying, I would have to search for the documentation based on the micro tasks (e.g. Reverse elements in an array) that would preform the necessary function of the code. I am honestly so grateful that this forum exists, and really do appreciate how more experienced coders are helping out us beginners. It just makes me want to do the same when I am more experienced. Thanks.