+ 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); }
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.
+ 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
+ 2
Thank you for your answer. I have found many other answers, but I wanted to know what is the problem with my code.
+ 2
I see thanks a lot.