The snail climbs up 7 feet each day and slips back 2 feet each night. How many days will it take the snail to get out of a well | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The snail climbs up 7 feet each day and slips back 2 feet each night. How many days will it take the snail to get out of a well

9th Apr 2021, 2:00 PM
Chandan Chhetry
Chandan Chhetry - avatar
11 Answers
- 1
Chandan Chhetry Don't write complex code. Solutions are already given in shared thread.
10th Apr 2021, 4:15 AM
A͢J
A͢J - avatar
+ 5
show your attempt first
9th Apr 2021, 2:05 PM
ÃKR
ÃKR - avatar
+ 4
As Akr bro said, your try is also important so that we can tell you where you are wrong! Hint : loop will climb and condition will fall you down
9th Apr 2021, 2:10 PM
Abhiyantā
Abhiyantā - avatar
9th Apr 2021, 2:42 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
+ 2
ok
9th Apr 2021, 2:11 PM
Chandan Chhetry
Chandan Chhetry - avatar
+ 2
ok
10th Apr 2021, 3:57 AM
Chandan Chhetry
Chandan Chhetry - avatar
+ 2
Right 🅰🅹 (Challenge Accepted) Sir!! But I think Chandan Chhetry have to try with his own effort this, to take the real benefit of practice!! Don't write complex code as Sir said but try to make by your own
10th Apr 2021, 4:18 AM
Abhiyantā
Abhiyantā - avatar
0
my answer: function main() { var depth = parseInt(readLine(42), 10); //your code goes here var up=7; var dwn=2 while(depth){ case 1; var r=(up-dwn) return r case 2; var r2=((r+up)-dwn) return r2 case 3; var r3=((r2+up)-dwn) case 4; var r4=((r3+up)-dwn) case 5; var r5=((r4+up)-dwn) case 6; var r6=((r5+up)-dwn) } console.log(r6) }
10th Apr 2021, 3:25 AM
Chandan Chhetry
Chandan Chhetry - avatar
0
Why are you returning ?!
10th Apr 2021, 3:56 AM
Abhiyantā
Abhiyantā - avatar
0
Rishav Tiwari Yes always try to do self but try in more ways. There maybe many ways to solve one problem.
10th Apr 2021, 4:24 AM
A͢J
A͢J - avatar