+ 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.
6 Respuestas
+ 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);
}
+ 2
Please post what you have tried
+ 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
0
It should be "sum+7>=depth"
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);
}
0
this is my one line solution
console.log(Math.round(depth/5))
it works with all cases but idk if it is right