Who can help me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Who can help me?

function main() { var depth = parseInt(readLine(), 10); //ваш код if ((depth-2)%5==0) { console.log((depth-7)/5+1) }else if ((depth - 2)%5!=0){ console.log((depth-(depth%5))/5+1) } } in this exercise, all the tests come out correct, except for the first hidden one. Can't figure out what the error is? Who can give you a hint? The exercise is called the Snail.

21st Dec 2020, 10:05 AM
John List
4 Answers
+ 2
The code coach is about in how many days will the snail be equal or greater than given depth.so a while or for loop will be used here and an increment operation starting from 0 and grow up until reaching the condition.
21st Dec 2020, 12:36 PM
HBhZ_C
HBhZ_C - avatar
+ 1
I understood that here it is necessary to use while or for, but now my head is full of studies, so I can not sufficiently understand the topic of cycles to operate freely with them, so often I decide as I can, but it turns out badly. I decided to ask if someone knows how to solve it this way. But apparently we'll have to wait for the holidays.)
21st Dec 2020, 12:56 PM
John List
0
hint: if you remove +1 case 3 becomes correct like : console.log((depth-(depth%5))/5) hint from code coach: You can use a loop to calculate the distance the snail covers each day, and break the loop when it reaches the desired distance.
21st Dec 2020, 11:01 AM
Bahhaⵣ
Bahhaⵣ - avatar
0
Yes, in this case, the third test is solved, but the others are not solved. And it is necessary that everyone decides.
21st Dec 2020, 11:49 AM
John List