Snail in the Well Test Case #3 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Snail in the Well Test Case #3

I'm having a hard time completing the Snail in the Well problem in the JS course, all test cases are approved but the third one. I can't have any information about it as it is locked. My apologies if the question has already been asked, I can't seem to click on a forum thread as it redirects me to my profile page. Could someone tell me what the test case #3 is ? Or send me their code so I can see what's missing in mine ? Thanks.

8th Feb 2021, 2:53 PM
Nathan Deltour
Nathan Deltour - avatar
6 Answers
+ 3
Here's my code : function main() { var depth = parseInt(readLine(), 10); //your code goes here var sum = 0; var i = 0; while (sum <= depth) { sum += 5; i++; if (sum + 7 === depth) { i++; break; } } console.log(i); }
8th Feb 2021, 2:57 PM
Nathan Deltour
Nathan Deltour - avatar
+ 2
Please post what you have tried
8th Feb 2021, 2:56 PM
Atul [Inactive]
+ 1
to be able to click and be correctly redirected to the target thread, you first need to log out, then log in when it ask to you... I hope this workaround is needed for a limited time only, even if I strongly doubt of that ;P
8th Feb 2021, 3:05 PM
visph
visph - avatar
0
It should be "sum+7>=depth"
8th Feb 2021, 3:05 PM
Abhay
Abhay - avatar
0
function main() { var depth = parseInt(readLine(), 10); var height = 0; var day = 0; //your code goes here while( height < depth) { day++; height += 7; if(height >= depth) { break; } else { height -= 2; } } console.log(day); }
12th Jan 2022, 12:29 PM
Julian Grosser
0
this is my one line solution console.log(Math.round(depth/5)) it works with all cases but idk if it is right
31st Oct 2022, 11:04 PM
Moath Hussam
Moath Hussam - avatar