Snail in the Well ( Help me out ) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Snail in the Well ( Help me out )

function main() { var depth = parseInt(readLine(), 10); dis = 0; day=0; //your code goes here for (i=0 ; i<= depth ; i++) { dis = dis + 7 - 2; day++; if ( dis > depth) { break; } //console.log("Day " + day + " = " + dis); } console.log(day); }

22nd Nov 2022, 3:54 AM
Samundra Khanal
Samundra Khanal - avatar
1 Answer
+ 3
Hi! your snail has to crawl 7 feet up, then you check if it has reached the edge of the well, if not --->>> it falls two feet down. and in your case, it falls immediately, before checking. think about it.
22nd Nov 2022, 5:37 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar