- 2

What is the code of snail in the well? I am confused. Please say me the code.

Please help me. function main() { var depth = parseInt(readLine(), 10); //your code goes here var i=7-2; do{ console.log(i); i++; } while(i<=10); }

15th Apr 2021, 7:10 AM
TD Gaming
TD Gaming - avatar
4 RĂ©ponses
+ 5
Hi! First, please, show us your attempt!
15th Apr 2021, 7:32 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
TD Gaming Please show your attempts. Someone will help you
15th Apr 2021, 11:59 PM
â€ïžđŸ˜PreranađŸ˜â€ïž
â€ïžđŸ˜PreranađŸ˜â€ïž - avatar
+ 1
first, divide in time the snail's crawl up and its descent down. you have to think like a snail: during the day you crawl seven feet up and ONLY at night you go down two feet. and you don't use the depth variable in your program at all. depth is your specified number of feet of the length of the well. so do this: keep an independent record of the number of days passed. crawl 7 feet up during the day, then compare this distance with the total length of the well. if this distance is greater than or equal to the length of the well, then super! You're out! output the number of days spent to the console. if you don't crawl out of the well, the night begins - and you go down two feet. then a new day begins...
16th Apr 2021, 4:59 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
function main() { var depth = parseInt(readLine(), 10); //tu cĂłdigo va aquĂ­ var d = 0; // dĂ­as var c = 0; // caracol while (c < depth) { c += 7 - 2; d += 1; if (c > depth) { if (c - 2 <= depth) { console.log(d); break; } else if (c > depth) { console.log(d - 1); break; } } } }
6th Jun 2021, 6:40 PM
Kevin Alexander Alvarez Echeverri
Kevin Alexander Alvarez Echeverri - avatar