# breaking it down medium

The Magic Beanstalk

By day the beanstalk grows; by night it slips back down. When does it top the garden wall? 🌱

You get the wall height, daily growth, and nightly slip (growth beats slip). The stalk starts at 0 and the wall is topped DURING a day's growth. Print that day's number.

Example:

Input: height = 10, growth = 3, slip = 1 Output: 5

Each day/night cycle nets +2 overall, but the check happens mid-day at the peak. After 4 full cycles the stalk sits at 8, and on day 5's growth it reaches 8 + 3 = 11, topping the 10-height wall.

💡 need a hint?

brk-magic-beanstalk.py🔒 given lines are locked — write your code in between
loading...