- 4

program in javascript

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 with the given depth?

6th Dec 2020, 7:21 AM
Avantika Damdhar
Avantika Damdhar - avatar
7 Respostas
+ 5
Avantika Damdhar The QUESTIOn isn't clear.. the attempt isn't there.. there's no elaboration.. Yet you think that we can help you exactly what you are willing for?
6th Dec 2020, 10:00 AM
Piyush
Piyush - avatar
+ 4
Avantika Damdhar First show your attempts.
6th Dec 2020, 7:29 AM
A͢J
A͢J - avatar
+ 2
DIY ( Do It Yourself )
6th Dec 2020, 10:05 AM
Anurag Saikia
+ 2
Suppose your input is 32. In one day the snail progress is 7-2 = 5 inch. You need 30/5= 6 days to finish . The 2 inch remainder will be finished in the next day. So the, total days is 6 + 1 = 7 days. Hope it simple and helpful.
9th Dec 2020, 10:58 PM
Fajri Illahi
Fajri Illahi - avatar
+ 1
answer is function main() { var depth = parseInt(readLine(), 10); //your code goes here var rem=depth%5; if(rem>2){ var result=(depth-rem); console.log((result/5)+1); } else { var result=(depth-rem); console.log(result/5); } }
7th Dec 2020, 6:38 AM
Avantika Damdhar
Avantika Damdhar - avatar
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var rem=depth%5; var result=(depth-rem); console.log((result/5)+1); }
6th Dec 2020, 11:07 AM
Avantika Damdhar
Avantika Damdhar - avatar
0
Hi Avantika Damdhar can you elaborate ho you solved that? Thanks
8th Dec 2020, 2:59 PM
Zahor Mohammed Aziz