Snail in the well problem not getting! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Snail in the well problem not getting!

function main() { var depth = parseInt(readLine(), 10); //your code goes here var c=0; var sum=0; for (i=0;i>=depth;i+=sum) { sum=i+7-2; c++; } document.write(c); }

21st Dec 2020, 8:10 AM
Jayanth
Jayanth - avatar
4 Answers
+ 3
function main() { var depth = parseInt(readLine(), 10); var a = 0; var day = 0 while(a <= depth) { a += 7 day += 1 if (a >= depth) { break; } a -= 2 } console.log(day) } Try this code.
21st Dec 2020, 8:27 AM
Shounak
Shounak - avatar
+ 1
thanks
21st Dec 2020, 8:32 AM
Jayanth
Jayanth - avatar
+ 1
Jayanth😎 Welcome
21st Dec 2020, 8:51 AM
Shounak
Shounak - avatar
0
I'm trying to get this code It's working prop.
20th Jan 2021, 9:03 PM
Himanshu Thakur
Himanshu Thakur - avatar