Can somebody explayne me plz lost hope | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Can somebody explayne me plz lost hope

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. The task name: snail in the well :)

21st Jun 2021, 11:27 AM
Edgaras Starkutis
Edgaras Starkutis - avatar
1 Antwort
+ 1
In a day snail climbs up 7 feet, if it not reach given depth (means not out of wall), then drops 2 feet. This will be repeated next days till it reached wall.. what else you not understanding?
21st Jun 2021, 12:38 PM
Jayakrishna 🇮🇳