Would someone help me?

Hi, Campers :wave:! I’m facing difficulty learning JavaScript I have reached the following challenge of freecodecamp.
I understand all concepts and methods correctly. The problem that I am facing is that I am unable to develop the algorithm for a single problem. After spending time, I went to the hint website and saw the solution then break the solution and practice it on paper. I am unable to solve a single problem on my own. Feeling frustrated that why I am unqualified to do it.
I need your help what should I do to improve my skills? How could I modify myself so that I can solve problems on my own?
I always try to maintain my morale and keep myself motivated but I am worried now. I thought I would be able to do it myself over time. This is just the beginning, that’s why I am struggling. But I don’t know what to do. Please help me and give me some advice.

Challenge: Mutations

Link to the challenge:

You might get a lot of benefit out of talking through the problem with us here on the forum. Often, articulating the problem and your thoughts alone is a big help (hence Rubber Duck Debugging. And then there’s the fact that we can help you work through the problem step by step instead of giving you the answer. We’ll ask you questions and talk to you about your own approach to help you do the work yourself.

In our community we always want people to feel comfortable asking for help at any stage.

5 Likes

Try this: draw picture, write down or think about how would you explain/teach this to someone very young like a small kid then try implementing that on code like have a mindset of teaching/trying to explain things to someone. My experiences has been that most of the times we know how to do it ourselves but it is trying to teach it to a computer is what we struggle with. Make points if you can like

  1. First do this
  2. Then do this etc

For example, I think you and almost everyone in the world would know if you ask them whether these two strings are same right?

["hello", "Hello"]

You look and it and think alright, they both say hello but the difference is the h being capital.

So how would you teach it to a someone much younger than you?

  1. first you take the first element of the array and compare it with second element while comparing ignore that the case of the letter that is whether its upper case or lower case. How would you do that? How would you treat Hello and hello as same? This could be tricky! Think, think. The solution is when you turn every element you compare to lower case. arr[0].toLowerCase or to uppercase then they basically become same. If they are same then return true.

  2. If they are different then return false.

  3. Now time to think a little hard. how would we teach someone much younger than us to say that these two are same too?

["Alien", "line"]

How would you do it. This is where you start to become a problem solver/puzzle solver. Think of it like a game, a fun game. Don’t stress and keep thinking.

I forgot how I solved it. But here is how I would do it.

First, I would check and point out which one is the shorter one. “Line” right?
Now I compare L to each letter of Alien, then I go to i then N then E
Of course lower casing it first.
l time to compare it with each letter of a l i e n does it match? yes
i time to compare it with each letter of a l i e n does it match? yes
n time to compare it with each letter of a l i e n does it match? yes
e time to compare it with each letter of a l i e n does it match? yes

If all the letters match then you would return true right? That’s how we humans would do. Actually different people would do it in different ways.

Now time to implement this logic into code.

How would you compare each letter of one string to each letter of other string. I think with str[i] where i goes from first to last letter of string 1 and then another loop where it goes through the another string. I will stress this here. Basics are important if you don’t know you need to go back and learn how to use for loop nested ones too if possible with paper and pen

Now next question is how would you add up the yesses if it match. You can set up a counter and add it every time it matches and at the end when the counter is equal to the length of the shorter string you return true. I’m not sure, this is fun part going and trying the logic, solving one bug after another. Once you start doing it, it can become tough but fun at the same time. For me it was almost addictive that I spent many hours a day doing it as I enjoyed it a lot

I hope you will enjoy it too even though its kind of hard.

And don’t beat yourself up algorithm scripting can be hard for everyone or take a while to go through. Work on it as much as possible instead of looking up the solutions.

5 Likes

There is some good advice here so I’ll just offer words of encouragement…

What you are experiencing is very common. Algorithmic thinking is different than programming thinking. I actually tested this once by teaching my friend (who has never coded) how different sorting algorithms work. Also, many times at algorithm meetups, coders who all different languages will hang out and talk about different algorithms.

A lot of people struggle with these, including some excellent coders, so you’re in good company. But the more algorithms you do, the better you get. Just keep at it. Don’t get frustrated.

If you search through the forum history I’m sure you’ll find several posts of people with similar struggles.

5 Likes

The first step when facing a problem like this is to ask yourself, how you as a human would solve it.
Surely checking letters in two words wouldn’t cause an issue.
Now think about how you could turn your actions into a description, a set of tasks. Basically breaking down your actions into a verbal algorithm - also known as pseudo-code.

Once you got that, you can think about how to translate into the programming language of your choice. Some might need more details than others.

If you advance your knowledge, you might pick up techniques and methods to improve.

The hard part for beginners is to basically forget their complex knowledge and dumb-down what they are doing to a level so stupid an unthinking machine can understand it.

Like, if I would face that task and would use a naive approach, I would look at each letter of the second word, lowercase it and look at every letter in the first word and check, if it as lowercase would be the same. If I can’t find a fitting pair, I’d say “false” if I find a pair for each letter, I’d say “true”.
It’s highly inefficient for various reasons, but it would work and the tests don’t require optimized code.

The main problem is ofcourse, this is not how I actually do it. My brain would maybe look for patterns, remember a couple letters it already found - does a lot of subconscious processing that would be super hard and inefficient to program → hence the challenge of dumbing down the commands.

3 Likes

well, a lot of people have already given great advice here it’s good and now about your question, i think you are doing great already because the first step in order to learn any language is to learn how to read it same is the case when it comes to real-world languages so if you can read written codes and understand how they work congratulations you just have completed the first step. Don’t worry if you have to do little google search or take a look at solutions just don’t stop and soon you will notice that your brain will start coming up the solutions of it’s own ah btw I recommend Pattern Printing to everyone who is new to programming don’t get discouraged if you will not be able to solve them by your own just try to solve them first give them some time and if you find that it’s impossible then take a look at a solution after some time your brain will automatically get used to this and you will come up with the solution of your own cheers :v:… YOU CAN DO IT YOU ARE ALREADY DOING GREAT

3 Likes

You are right @ArielLeslie I get benefits after discussing my matter here But I posted this problem here after spending time considering it. I will follow your advice. I will try to follow your and other techniques suggested by campers. Thank you

1 Like

You got this!
Happy coding :smiley:

1 Like

Thank you @ARQSoft for your encouraging advice. But I think it’s not appropriate to saw the solution every time. That’s what bothers me. I hope after following your and other campers advice Inshallah, one day I will be eligible to do it by myself. :innocent:

I’ll just chime in here that I also strongly recommend against looking at the solutions.

Looking at code that others have written and understanding how it works is an important skill, but it is utterly unrelated to the skill of solving problems on your own. Developing a habit of looking up solutions will impede your ability to create your own solutions. Research is a key part of the problem solving process, but habitually looking up the work of others to copy hurts your ability to problem solve.

We’re here to answer questions. I strongly recommend talking though the problem with others on the forum before crippling your problem solving skills by developing a habit of looking at the solutions before you’ve solved the problem.

This is hard, but you can learn how to do it without looking up solutions.

Thank you so much @kevinSmith. Your words proved valuable and encouraging for me. I will try my best and follow your guidance.

You are right @JeremyLT I was feeling worried that why I’m unable to do it by myself. I’m also against it. That’s why I posted here so that get some beneficial advice for it.

Wow @ankurchaulagain. You explained it in an absolute and perfect way. I never think of this kind of scenario. Your example has proved very helpful for me. Thank you. Afterward, I will try my best to accomplish my task in this way.

@Jagaya Thank you for answering my query in this absolute way. I hope this will prove effective and beneficial for me.

2 Likes

Excellent explanation! You really took the time to explain this well, great job.

2 Likes

Wish you best of Luck

1 Like

thank you so much for this explanation!!!

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.