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? Sample Input: 31 Sample Output: 6 Explanation: Let's break down the distance the snail covers each day: Day 1: 7-2=5 Day 2: 5+7-2=10 Day 3: 10+7-2=15 Day 4: 15+7-2=20 Day 5: 20+7-2=25 Day 6: 25+7=32 So, on Day 6 the snail will reach 32 feet and get out of the well at day, without slipping back that night

6/29/2022 2:44:47 PM

Abolfazl Abbaspour11 Answers

New AnswerYou can try this as well n is the input 7x - 2(x - 1) = n x = (n - 2) / 5 result -> x + (x % 5 != 0)

i = 0; for (; depth > 0;) { i++; depth -= 7 if (depth > 0) { depth += 2 } } console.log(i);

Hot Today

Audio auto play?
In a string, how can i separe important values in char or in different string values?
I don't understand This line.
Can anyone solve this the problem is in the formula
Can you make any money off sololearn?
What number will be alerted?
why is "&" used in scanf and not in getchar or gets [SOLVED]
Подскажите пожалуйста, как решить
Web Dev question
Is it possible

Sololearn Inc.

535 Mission Street, Suite 1591San Francisco, CA 94105

© 2022 Sololearn, Inc.

Send us a message