# Algorith intermediate impossible

Hello everybody !

I just have one question to reassure me.
I’m doing ‘Intermediate Algorithm Scripting’. I didn’t have too many problems with the old exercise for beginners, a little difficult, but I managed to understand… But the… the more I progress, the less I understand. On the first 10 I had to manage to do 3/4 alone, the rest I had to see the solution… but from the 10 impossible to find a solution, and the answer is so difficult to understand that I have the feeling more level…

Is it normal or not?

1 Like

Perfectly normal. But the more you code the more you’ll see the patterns, know the built-in functions and know what to google to figure out the solution.

1 Like

It is normal to struggle. Unfortunatly, looking at and copying the answer doesn’t really teach you how to solve these problems, it just teaches you how to look at and duplicate other people’s code.

but I can never find the solutions and I find it demotivating… I know that the more I will program, the more I will be able to succeed, but I thought that learning here would be more ‘gentle’…

Should I continue and try anyway? Or go back to the beginning and redo all the Algorithm?

I understand. I try but I block with each problem. I feel like I have more of a math problem than a programming problem.

1 Like

Ok I’ll do that, I’ll soon make one for the next problem because I can’t do it at all…

Can you give an example of a challenge and what exactly you’re struggling with?

I had a hard time understanding the statement. Then this one I looked at the answer to understand what to do, and when I see the answer, I am completely lost…

This one I couldn’t understand the statement too… And I still don’t understand why we just get the odd numbers except the 9…

The first one " Smallest Common Multiple" is a tricky one, so don’t feel bad if you couldn’t figure it out.
Basic approach (I didn’t check the hints so I may just be repeating them ):

Mod Edit: SOLUTION REDACTED

In Sum All Odd Fibonacci Numbers you need to generate a Fibonacci sequence which is

``````1, 1, 2, 3, 5, 8, 13, 21...
``````

and sum the odd numbers from that sequence (there is no 9).

``````1 + 1 + 3 + 5 + 13 + 21...
``````

First try to write a function that generates Fibonacci sequence (array of values).
Second go over that array and sum the odd values.
This is not the optimal solution and it may timeout on bigger numbers, but it’s a start.
Then do it in one loop.

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

1 Like

OP already said that they checked hints and was still lost so I posted a solution with comments describing how to approach it with opportunity to ask questions. If someone wants to cheat they’ll just copy/paste from hints section.

Mods should mod and not blindly delete any “solution” they see.

No providing solutions. Those are the rules.

The Smallest Common Multiple is a bit different than most of the rest. I honestly recommend that people look up the GCD based algorithm on Wikipedia and implement that. Looking up an algorithm and converting it into code is an important skill to practice. But it’s totally normal to get stuck on that challenge and lots of people open a topic with their partial code and describing where they got stuck.

The Sum All Odd Fibonacci Numbers is another classic algorithms/interviews type problem. The instructions can be confusing if you haven’t done one before. It’s totally normal to open a topic just to clarify the question. This is another problem where I like looking at the Wikipedia article as well.

1 Like

Thanks for all the replies, that’s great!

Thank you for the explanations. In fact I had a big problem: I want to redo each time on my own without searching the internet except for the mdn documentation… so I dare not look at how fibonacci works and copy and convert into lines of code…

I will redo the two exercises, and will send a message if I have any problems. Thank you so much, it’s an amazing community!

I take this opportunity to ask more questions.

Currently I am learning javascript. I really try to handle it well, I also work on the codewars site from time to time, and I do mockups on the frontEndMentor site.

Do you have any other work ideas currently to improve myself in javascript before learning React? And to start touching the frameworks?

1 Like

Thanks a lot to jenovs and JeremyLT

1 Like

Good choice - while it is nice to try things on your own, I’ll like to remind of one thing: people actually invented algorithms, sometimes even got their names attached to it.

You don’t have to come up with every solution on your own. You can try, but if you get stuck, do what every other developer would do: Ask.

If I’d ask you to sort an array - it would be outstandingly amazing if you found a efficient solution. But reality is, there are like half a dozen proven and effective sorting algorithms. And if any developer is asked to sort something, they either reproduce a memorized one of them or look one up.

2 Likes

Hi @Alexandre-Chs,

3.3 Domain Knowledge

It is natural to wonder what knowledge it takes to code up the body of a function. A little bit of reflection tells you that this step demands an appropriate grasp of the domain of the program. Indeed, there are two forms of such domain knowledge:

1. Knowledge from external domains, such as mathematics, music, biology, civil engineering, art, and so on. Because programmers cannot know all of the application domains of computing, they must be prepared to understand the language of a variety of application areas so that they can discuss problems with domain experts. Mathematics is at the intersection of many, but not all, domains. Hence, programmers must often pick up new languages as they work through problems with domain experts.
1. Knowledge about the library functions in the chosen programming language. When your task is to translate a mathematical formula involving the tangent function, you need to know or guess that your chosen language comes with a function such as BSL’s tan. When your task involves graphics, you will benefit from understanding the possibilities of the 2htpd/image library.
Since you can never predict the area you will be working in, or which programming language you will have to use, it is imperative that you have a solid understanding of the full possibilities of whatever computer languages are around and suitable.

IMO “Smallest Common Multiple”[1] and “Sum All Odd Fibonacci Numbers”[2] are examples of `1.Knowledge from external domain`. Because the difficulty is not about “how to implement/express the solution”, the difficulty is find the solution.
I don’t think that is possible to acquire this type of knowledge with hours of coding (in this case you will have to rediscover the smallest common multiple algorithm from scratch to “pass” the exercise).

… ideas currently to improve myself in javascript before learning React? And to start touching the frameworks?

Take a look at “Chapter 3 : Functional Programming with JavaScript”, of the book “Learning React by Alex Banks and Eve Porcello”[3]

Transforming Data

1. Joining Array Items
2. Filtering Arrays
3. Filtering Array Function
4. Mapping Arrays
5. Creating Objects with .map()
6. Updating Array of Objects
7. Editing Arrays of Objects
8. Object.keys()
9. Reducing Arrays
10. Array.reduce() Shorter Syntax
11. Colors Hash
12. distinctColors()

If you look at `2. Filtering Arrays` you will find something like this:

``````let list      = [1,0,0,1,1]
let onlyOnes = list.filter(element => element === 1)
let onlyZeros = list.filter(element => element === 0)
console.log('onlyOnes: ',  onlyOnes)
console.log('onlyZeros:', onlyZeros)
``````

Try to get familiar with that kind of operations.

Cheers and happy coding

Notes:

2 Likes

Thank you very much I will see the references, it’s perfect!