Dissapoointed with my overanalytical, complex thinking

Tell us what’s happening:
Sometimes I get disappointed with my complex, over-analytical thinking.
The problem is that the algorithm had much more simpler solution and I over-analyzed it.

I found the solution to the problem but I couldn’t think of any much more simpler solutions and that’s what got me disappointed.

I do that a lot and sometimes I think I do not have what it takes to become a great programmer.

long story short:

  1. I forget many methods
  2. I complicate things
  3. Even if I do 0 mistakes, I have a problem with finding the most, shortest, simple, accurate solutions.
  4. I get disappointed with my overthinking

Compare my solution with the solutions available here:

Your code so far


function mutation(arr) {
let biggerWord = [];
let smallerWord = [];
if (arr[0].length > arr[1].length) {
  biggerWord = arr[0].toLowerCase().split("");
  smallerWord = arr[1].toLowerCase().split("");
} else {
  biggerWord = arr[0].toLowerCase().split("");
  smallerWord = arr[1].toLowerCase().split("");
}

 
let truthArr = [];
for (let i = 0; i < biggerWord.length; i++) {
  for (let j = 0; j < smallerWord.length; j++) {
    if (truthArr.indexOf(smallerWord[j]) >= 0 ) {
      continue
    } else if (smallerWord[j] == biggerWord[i]) {
      truthArr.push(smallerWord[j]);
    }
  }
}

for (let i = 0; i < truthArr.length; i++) {
  for (let j = 0; j < smallerWord.length; j++) {
    if (truthArr.indexOf(smallerWord[j]) == -1) {
      return false
    }
  }
}
return true;
}

mutation(["hello", "Hello"])
mutation(["voodoo", "no"])

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0.

Challenge: Mutations

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations

4 Likes

Don’t beat yourself up over it: even the most experienced of us will sometimes overthink a problem and write too much code to solve it. Writing code is often a very iterative process, involving going back and cleaning up old code. What you’ll want to do is go back and read your code, and recognize different patterns in your code in order to rewrite them with shorter idioms. Pretty much the same as refactoring else’s code, but in this case the someone else is your past self.

In this case, you’re looping over an array that you’re then using to test for a truth condition. When you see that sort of thing, you’ll probably want to rewrite later using Array.filter(). Eventually that’ll be the first thing you reach for, but it’s a habit you’ll only form through practice.

5 Likes

hope so…
i just hope stop doing these mistakes…
i know i’m inexperienced but still I wonder if I’m gonna make it and find a good job with mistakes like that…

How’s it going now? Any luck in finding a job? What cool stuff did you learn in the meantime?
I hope you didn’t give up.

2 Likes

I didn’t.
I opened up my own business.
At the moment I design web pages & e-shops with WordPress & WooCommerce.
The cool thing is I can customize stuff here and there.

and I’m hoping to start working as a Full Stack Web Developer soon.

I have opened my business web-site with Gatsby, ReactJS and TailWind
There’s a ton of stuff I don’t know yet.

Have a look at my business website here:
https://www.web-coders.net

It’s not perfect and there’s a lot of room of improvement too.
I created it with Gatsby because I would like to have my functionalities, such as:

  • Customers be able to log in and download invoices/send requests/chat
  • Make it to have a score of 100 in SEO
  • Convert it in a commerce: Customers will be able to fill up a form and get an offer for the Website/Webapp they want.

I’m also working on my own projects.
There’s a ton of ideas and vision on what I want to do.

For now having established an agency makes me feel proud.

2 Likes

Glad to hear that you kept going, I’m also starting and I understand how that impostor syndrome feels like. I talked even with senior Devs and they still get that sometimes. There will always be a ton of stuff you’ll not know in this field and I came to peace with that.

I like the website’s look, the Solar System, and the “scrollable background” (or whatever you call that).
How do you measure the SEO score? Is there a tool for that.

Oh, I noticed the LinkedIn link in the footer doesn’t work, it redirects to a “Page not found” situation. Maybe check that out :+1:

1 Like

A post was split to a new topic: Please help with this algorithm challenge