Hi....does anyone have any idea how to solve the "Snail in the well" project for JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Hi....does anyone have any idea how to solve the "Snail in the well" project for JavaScript?

29th Oct 2021, 12:47 PM
Lulu The Closet Snob
Lulu The Closet Snob - avatar
3 Answers
+ 1
function main() { var depth = parseInt(readLine(), 10); //your code goes here var depthCover = 0; for (day = 1; day<=depth; ++day){ if (depth - depthCover > 7){ depthCover += 5; }else { break; } } console.log(day) }
13th Nov 2021, 8:55 AM
Abdisalam Hassan
Abdisalam Hassan - avatar
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var climb = 7 var slip = 2 var days = 1 for (workdone = climb ;workdone < depth;days = days+1 ) { if (workdone==depth) { break; } workdone = workdone + climb; workdone = workdone - slip; } console.log(days) }
29th Oct 2021, 12:59 PM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar