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!

+2

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

4/9/2021 2:00:28 PM

Chandan Chhetry

11 Answers

New Answer

+3

Chandan Chhetry Don't write complex code. Solutions are already given in shared thread.

+4

show your attempt first

+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

+3

https://www.sololearn.com/discuss/2746840/?ref=app

+2

+2

Why are you returning ?!

+2

+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

+2

Rishav Tiwari Yes always try to do self but try in more ways. There maybe many ways to solve one problem.

+1

Chandan Chhetry Use search option to get solution https://www.sololearn.com/discuss/2665192/?ref=app https://www.sololearn.com/discuss/2618113/?ref=app https://www.sololearn.com/discuss/2617598/?ref=app https://www.sololearn.com/discuss/2624694/?ref=app https://www.sololearn.com/discuss/2690678/?ref=app

+1

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) }