Snell in the well problem of JS course | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Snell in the well problem of JS course

I got stuck at this problem. I don't get why this code isn't working. Can anyone give me hint ? function main() { var depth = parseInt(readLine(), 10); //your code goes here var depth1 = 0,i = 1; do { depth1 +=5; i++; }while((depth1 + 7)<=depth); console.log(i); }

19th Dec 2020, 6:57 PM
The HeadsMan
The HeadsMan - avatar
4 ответов
+ 3
„The snail climbs up 7 feet each day and slips back 2 feet each night.“ In your code you do not check separatly as well as first, what value has depth in a day before night. Thus in cases where the depth1 will be reached during a day the result is by 1 more. For example for input 42 your result is 9 and should be 8.
19th Dec 2020, 9:52 PM
JaScript
JaScript - avatar
+ 2
The hint will be to read carefully the description and do what you there see. If you like this will help you: https://code.sololearn.com/WKRV33S7kCTk/?ref=app
19th Dec 2020, 7:26 PM
JaScript
JaScript - avatar
+ 2
Thank you for your answer. I have found many other answers, but I wanted to know what is the problem with my code.
19th Dec 2020, 8:38 PM
The HeadsMan
The HeadsMan - avatar
+ 2
I see thanks a lot.
24th Dec 2020, 5:43 PM
The HeadsMan
The HeadsMan - avatar