### Task
 Each day a plant is growing by `upSpeed` meters. Each night that plant's height decreases by `downSpeed` meters due to the lack of sun heat. Initially, plant is 0 meters tall. We plant the seed at the beginning of a day. We want to know when the height of the plant will reach a certain level.

### Example

 For `upSpeed = 100, downSpeed = 10 and desiredHeight = 910`, the output should be `10`.
 
 ```
 After day 1 --> 100
 After night 1 --> 90
 After day 2 --> 190
 After night 2 --> 180
 After day 3 --> 280
 After night 3 --> 270
 After day 4 --> 370
 After night 4 --> 360
 After day 5 --> 460
 After night 5 --> 450
 After day 6 --> 550
 After night 6 --> 540
 After day 7 --> 640
 After night 7 --> 630
 After day 8 --> 730
 After night 8 --> 720
 After day 9 --> 820
 After night 9 --> 810
 After day 10 --> 910 
 ```
 
 For `upSpeed = 10, downSpeed = 9 and desiredHeight = 4`, the output should be `1`.
 
 Because the plant reach to the desired height at day 1(10 meters).
 
 ```
 After day 1 --> 10
 ```

### Input/Output

```if-not:sql
 - `[input]` integer `upSpeed`

    A positive integer representing the daily growth.

    Constraints: `5 ≤ upSpeed ≤ 100.`


 - `[input]` integer `downSpeed`

    A positive integer representing the nightly decline.

    Constraints: `2 ≤ downSpeed < upSpeed.`


 - `[input]` integer `desiredHeight`

    A positive integer representing the threshold.

    Constraints: `4 ≤ desiredHeight ≤ 1000.`

 - `[output]` an integer

    The number of days that it will take for the plant to reach/pass desiredHeight (including the last day in the total count).
```
```if:sql
## Input

~~~
-----------------------------------------
|     Table     |    Column      | Type |
|---------------+----------------+------|
| growing_plant | down_speed     | int  |
|               | up_speed       | int  |
|               | desired_height | int  |
-----------------------------------------
~~~

### Columns
* `up_speed`: A positive integer representing the daily growth. Constraints: `5 ≤ up_speed ≤ 100.`
* `down_speed`: A positive integer representing the nightly decline. Constraints: `2 ≤ down_speed < up_speed.`
* `desired_height`: A positive integer representing the threshold. Constraints: `4 ≤ desired_height ≤ 1000.`

## Output

~~~
-------------------
|  Column  | Type |
|----------+------|
| id       | int  |
| num_days | int  |
-------------------
~~~

`num_days` is the number of days that it will take for the plant to reach/pass desiredHeight (including the last day in the total count).
```

Difficulty: EASY

Starter code:
def growing_plant(upSpeed, downSpeed, desiredHeight):
	

Solutions:
from math import ceil

def growing_plant(up, down, h):
	return max(ceil((h - down) / (up - down)), 1)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	days = 1
	height = upSpeed
	while height < desiredHeight:
		height += upSpeed - downSpeed
		days += 1
	return days


from math import ceil
growing_plant = lambda u, d, h: max([ceil((h - u) / (u - d)), 0]) + 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	current = 0
	counter = 1
	while current < desiredHeight:
		current = current + upSpeed
		if current >= desiredHeight:
			return counter
		current = current - downSpeed
		counter = counter + 1
	return counter


def growing_plant(upSpeed, downSpeed, desiredHeight):
	try:
		assert 5 <= upSpeed <= 100
		assert 2 <= downSpeed < upSpeed
		assert 4 <= desiredHeight <= 1000
	except:
		return 1
	day = 0
	plantHeight = 0
	while plantHeight < desiredHeight:
		day += 1
		plantHeight += upSpeed
		if plantHeight >= desiredHeight:
			break
		else:
			plantHeight -= downSpeed
	return day


def growing_plant(upSpeed, downSpeed, desiredHeight):
	return max((desiredHeight - upSpeed - 1) // (upSpeed - downSpeed) + 1, 0) + 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	i = 1
	height = 0
	while True:
		height = height + upSpeed
		if height >= desiredHeight:
			break
		else:
			height = height - downSpeed
		i = i + 1
	return i


from math import ceil

def growing_plant(up_speed, down_speed, desired_height):
	return max(0, ceil((desired_height - up_speed) / (up_speed - down_speed))) + 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if desiredHeight <= upSpeed:
		return 1
	days = int(desiredHeight / upSpeed)
	desiredHeight -= days * (upSpeed - downSpeed)
	return days + growing_plant(upSpeed, downSpeed, desiredHeight)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = 0
	day = 1
	num_days = 0
	while height < desiredHeight:
		if day == True:
			height += upSpeed
			day = 0
			num_days += 1
		else:
			height -= downSpeed
			day = 1
	return num_days


growing_plant = lambda u, d, h: max(1, int((h - u) / (u - d) + 1.99))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	day = 1
	plant_height = 0
	while True:
		plant_height += upSpeed
		if plant_height >= desiredHeight:
			return day
		plant_height -= downSpeed
		day += 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	h = 0
	n = 1
	h = n * upSpeed - (n - 1) * downSpeed
	while h < desiredHeight:
		n += 1
		h = n * upSpeed - (n - 1) * downSpeed
	return n


growing_plant = lambda u, d, h: 0 - max(h - d, 1) // (d - u)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	desiredHeight -= upSpeed
	if desiredHeight < 0:
		desiredHeight = 0
	return -(-desiredHeight // (upSpeed - downSpeed)) + 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	progress = upSpeed - downSpeed
	total = 1
	while upSpeed < desiredHeight:
		upSpeed += progress
		total += 1
	return total


def growing_plant(upSpeed, downSpeed, desiredHeight):
	i = upSpeed
	j = 1
	while i < desiredHeight:
		i += upSpeed - downSpeed
		j = j + 1
	return j


import math

def growing_plant(upSpeed, downSpeed, desiredHeight):
	oneDay = upSpeed - downSpeed
	if desiredHeight - oneDay <= 0 or desiredHeight <= upSpeed:
		return 1
	sum = 0
	count = 0
	while desiredHeight - downSpeed > sum:
		sum += oneDay
		count += 1
	return count


from math import ceil

def growing_plant(u, d, h):
	return max(1, min(ceil(h / (u - d)), ceil((h - d) / (u - d))))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	plantHeight = 0
	day = 0
	night = 0
	while plantHeight != desiredHeight:
		day += 1
		plantHeight += upSpeed
		if plantHeight >= desiredHeight:
			return day
		night += 1
		plantHeight -= downSpeed
		if plantHeight >= desiredHeight:
			return night


import unittest

def growing_plant(up_speed, down_speed, desired_height):
	result = 0
	day = 0
	while True:
		day += 1
		result += up_speed
		if result >= desired_height:
			break
		result -= down_speed
		if result >= desired_height:
			break
	return day

class TestGrowingPlant(unittest.TestCase):

	def test_should_return_1_when_desiredheight_is_equal_less_than_upspeed(self):
		self.assertEqual(growing_plant(up_speed=10, down_speed=9, desired_height=4), 1)

	def test_growing_plant_common_case(self):
		self.assertEqual(growing_plant(up_speed=100, down_speed=10, desired_height=910), 10)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	(h, c) = (upSpeed, 0)
	while h < desiredHeight:
		h = h - downSpeed + upSpeed
		c = c + 1
	return c + 1


def growing_plant(u, d, h):
	for i in range(1000):
		if h - u <= 0:
			return i + 1
		h += d - u


def growing_plant(up_speed, down_speed, desired_height):
	count = 1
	height = up_speed
	while height < desired_height:
		height -= down_speed
		height += up_speed
		count += 1
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = upSpeed
	counter = 1
	if height >= desiredHeight:
		return counter
	else:
		while height < desiredHeight:
			height += upSpeed - downSpeed
			counter += 1
		return counter


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if upSpeed >= desiredHeight:
		return 1
	return int(1 + (desiredHeight - upSpeed) / (upSpeed - downSpeed) + bool((desiredHeight - upSpeed) % (upSpeed - downSpeed)))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	count = 0
	while desiredHeight >= 0:
		count += 1
		desiredHeight -= upSpeed
		if desiredHeight <= 0:
			break
		desiredHeight += downSpeed
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	return max(1, int(0.99 + (desiredHeight - downSpeed) / (upSpeed - downSpeed)))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	t = 0
	h = 0
	while True:
		t += 1
		h += upSpeed
		if h >= desiredHeight:
			return t
		h -= downSpeed


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if upSpeed >= desiredHeight:
		return 1
	days = 0
	plant = 0
	while desiredHeight > plant:
		if plant + upSpeed >= desiredHeight:
			days += 1
			break
		else:
			plant += upSpeed - downSpeed
			days += 1
	return days


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if upSpeed >= desiredHeight:
		return 1
	else:
		desiredHeight_after_first_day = desiredHeight - upSpeed
		increment_each_day = upSpeed - downSpeed
		if desiredHeight_after_first_day % increment_each_day == 0:
			return desiredHeight_after_first_day // increment_each_day + 1
		else:
			return desiredHeight_after_first_day // increment_each_day + 2


def growing_plant(u, d, h):
	days = growth = 0
	while True:
		days += 1
		growth += u
		if growth >= h:
			return days
		growth -= d


def growing_plant(upSpeed, downSpeed, desiredHeight):
	cnt = 1
	for i in range(upSpeed, desiredHeight, upSpeed - downSpeed):
		cnt += 1
	return cnt


def growing_plant(upSpeed, downSpeed, desiredHeight):
	i = 0
	total = 0
	up = 0
	if desiredHeight == 0:
		return 1
	while total < desiredHeight and up < desiredHeight:
		i += 1
		up = total + upSpeed
		total = total + upSpeed - downSpeed
	return i


def growing_plant(up, down, desired):
	(res, day) = (0, 0)
	while True:
		res += up
		day += 1
		if res >= desired:
			return day
		res -= down


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = days = 0
	while height <= desiredHeight:
		days += 1
		height += upSpeed
		if height >= desiredHeight:
			break
		height -= downSpeed
	return days


import math

def growing_plant(upSpeed, downSpeed, desiredHeight):
	if upSpeed >= desiredHeight:
		return 1
	else:
		return math.ceil((desiredHeight - downSpeed) / (upSpeed - downSpeed))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	result = 0
	height = 0
	while True:
		result += 1
		height += upSpeed
		if height >= desiredHeight:
			break
		height -= downSpeed
	return result


import math

def growing_plant(upSpeed, downSpeed, desiredHeight):
	(days, height) = (0, 0)
	while True:
		days += 1
		height += upSpeed
		if height >= desiredHeight:
			return days
		height -= downSpeed


def growing_plant(up_speed, down_speed, desired_height):
	current_height = 0
	days_gone = 0
	if up_speed >= 5 and up_speed <= 100 and (down_speed >= 2) and (down_speed < up_speed) and (desired_height >= 4) and (desired_height <= 1000):
		while True:
			days_gone += 1
			current_height += up_speed
			if current_height < desired_height:
				current_height -= down_speed
			else:
				return days_gone
				break
	else:
		return 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = 0
	n = 0
	while height < desiredHeight:
		height += upSpeed
		n += 1
		if height < desiredHeight:
			height -= downSpeed
		else:
			break
	return n if upSpeed < desiredHeight else 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	for i in range(1, 1000):
		if i * (upSpeed - downSpeed) >= desiredHeight or (i - 1) * (upSpeed - downSpeed) + upSpeed >= desiredHeight:
			return i


def growing_plant(upSpeed, downSpeed, desiredHeight):
	(d, h) = (0, 0)
	while True:
		d += 1
		h += upSpeed
		if h >= desiredHeight:
			return d
		else:
			h -= downSpeed


def growing_plant(u, d, de):
	n = 0
	m = 0
	while de >= n:
		m += 1
		n += u
		if n >= de:
			break
		n -= d
	return m


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if upSpeed >= desiredHeight or desiredHeight == 0:
		return 1
	res = int((desiredHeight - upSpeed) / (upSpeed - downSpeed))
	if (desiredHeight - upSpeed) % (upSpeed - downSpeed) > 0:
		res += 1
	return res + 1


from math import ceil

def growing_plant(upSpeed, downSpeed, desiredHeight):
	if desiredHeight < upSpeed:
		return 1
	return ceil((desiredHeight - downSpeed) / (upSpeed - downSpeed))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = upSpeed
	day = 1
	while height < desiredHeight:
		height -= downSpeed
		height += upSpeed
		day += 1
	return day


import math

def growing_plant(upSpeed, downSpeed, desiredHeight):
	if desiredHeight - upSpeed > 0:
		return 1 + math.ceil((desiredHeight - upSpeed) / (upSpeed - downSpeed))
	return 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	if desiredHeight <= downSpeed:
		return 1
	currentHeight = 0
	i = 1
	while i < 100000:
		currentHeight += upSpeed
		if currentHeight >= desiredHeight:
			break
		currentHeight -= downSpeed
		i += 1
	return i


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = 0
	days = 0
	for i in range(1, 10000):
		days += 1
		height += upSpeed
		print(f'After day {i}: {height}')
		if height >= desiredHeight:
			break
		height -= downSpeed
		print(f'After night {i}: {height}')
		if height >= desiredHeight:
			break
	return days


def growing_plant(upSpeed, downSpeed, desiredHeight):
	count = 0
	sum = 0
	while sum < desiredHeight:
		sum += upSpeed
		if sum >= desiredHeight:
			return count + 1
		sum -= downSpeed
		count += 1
		print(sum)
	return 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	d = 0
	e = 0
	if desiredHeight < upSpeed:
		return 1
	else:
		while d < desiredHeight:
			d += upSpeed
			e += 1
			if d >= desiredHeight:
				return e
			else:
				d -= downSpeed
		return e


from math import ceil

def growing_plant(u, d, H):
	return ceil(max((H - u) / (u - d), 0)) + 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	(height, day) = (upSpeed, 1)
	while height < desiredHeight:
		print('After day ' + str(day) + ' --> ' + str(height))
		print('After night ' + str(day) + ' --> ' + str(height - downSpeed))
		height = height - downSpeed + upSpeed
		day += 1
	print('After day ' + str(day) + ' --> ' + str(height))
	return day


def growing_plant(upSpeed, downSpeed, desiredHeight):
	actualGrowth_afterDay = upSpeed
	number_of_days = 1
	dailyGrowth = upSpeed - downSpeed
	while actualGrowth_afterDay < desiredHeight:
		number_of_days += 1
		actualGrowth_afterDay += dailyGrowth
	return number_of_days


def growing_plant(upSpeed, downSpeed, desiredHeight):
	day = 1
	currentHeight = 0
	growing = True
	while growing:
		currentHeight += upSpeed
		print('After Day', day, 'Height:', currentHeight)
		if currentHeight >= desiredHeight:
			growing = False
		else:
			currentHeight -= downSpeed
			print('After Night', day, 'Height:', currentHeight)
			day += 1
	return day


def growing_plant(u, d, h):
	(r, c) = (u, 1)
	while r < h:
		r += u - d
		c += 1
	return c


def growing_plant(u, d, h):
	p = 0
	count = 1
	while h > p:
		p += u
		if h <= p:
			break
		p -= d
		count += 1
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = 0
	noite = 0
	dias = 0
	while desiredHeight > height and desiredHeight > noite:
		height += upSpeed
		noite = height
		height -= downSpeed
		dias += 1
	return dias


import math

def growing_plant(upSpeed, downSpeed, desiredHeight):
	height = 0
	days = 0
	while True:
		height += upSpeed
		days += 0.5
		if height >= desiredHeight:
			break
		height -= downSpeed
		days += 0.5
	return math.ceil(days)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	day = 0
	night = 0
	height = 0
	while height != desiredHeight:
		height = height + upSpeed
		day = day + 1
		if height >= desiredHeight:
			return day
		else:
			height = height - downSpeed
			night = night + 1
			if height == desiredHeight:
				return night
	return 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	return 1 + sum((upSpeed * d - downSpeed * (d - 1) < desiredHeight for d in range(1, 699)))


def growing_plant(upSpeed, downSpeed, desiredHeight):
	growth = upSpeed
	counter = 1
	while growth < desiredHeight:
		growth += upSpeed - downSpeed
		counter += 1
	return counter


def growing_plant(upSpeed, downSpeed, desiredHeight):
	daily_growth = upSpeed - downSpeed
	if desiredHeight <= upSpeed:
		return 1
	elif (desiredHeight - upSpeed) % daily_growth == 0:
		return (desiredHeight - upSpeed) // daily_growth + 1
	else:
		return (desiredHeight - upSpeed) // daily_growth + 2


def growing_plant(upSpeed, downSpeed, desiredHeight):
	t = 0
	day = 0
	while t < desiredHeight:
		day += 1
		t += upSpeed
		if t >= desiredHeight:
			return day
		t -= downSpeed
	return max(day, 1)


def growing_plant(upSpeed, downSpeed, desiredHeight):
	actual_height = 0
	counter = 0
	while actual_height <= desiredHeight:
		counter += 1
		actual_height += upSpeed
		if actual_height >= desiredHeight:
			return counter
		actual_height -= downSpeed


def growing_plant(upSpeed, downSpeed, desiredHeight):
	count = 0
	height = 0
	while height < desiredHeight:
		height += upSpeed
		count += 1
		if height >= desiredHeight:
			return count
		height -= downSpeed
	return 1


def growing_plant(upSpeed, downSpeed, desiredHeight):
	initial = upSpeed
	count = 1
	while initial < desiredHeight:
		initial += upSpeed
		initial -= downSpeed
		count += 1
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	current_height = 0
	counter = 0
	if desiredHeight == 0:
		counter = 1
		return counter
	else:
		while current_height < desiredHeight:
			current_height += upSpeed
			counter += 1
			if current_height >= desiredHeight:
				return counter
			else:
				current_height -= downSpeed


def growing_plant(upSpeed, downSpeed, desiredHeight):
	growth = upSpeed
	count = 1
	while growth < desiredHeight:
		growth -= downSpeed
		count += 1
		growth += upSpeed
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	count = 0
	a = 0
	if desiredHeight == 0:
		return 1
	while not a >= desiredHeight:
		a += upSpeed
		if a < desiredHeight:
			a -= downSpeed
		count += 1
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	dia = 0
	height = 0
	while True:
		height = height + upSpeed
		dia += 1
		if height >= desiredHeight:
			return dia
		height = height - downSpeed


def growing_plant(upSpeed, downSpeed, desiredHeight):
	h = 0
	counter = 1
	while h + upSpeed < desiredHeight:
		h += upSpeed - downSpeed
		counter += 1
	return counter


def growing_plant(upSpeed, downSpeed, desiredHeight):
	x = upSpeed
	output = 1
	while x < desiredHeight:
		x += upSpeed
		x -= downSpeed
		output += 1
	return output


def growing_plant(upSpeed, downSpeed, desiredHeight):
	init_height = 0
	day_count = 0
	if init_height == desiredHeight:
		return 1
	else:
		while init_height < desiredHeight:
			init_height += upSpeed
			day_count += 1
			if init_height >= desiredHeight:
				print(init_height, day_count)
				return day_count
				break
			else:
				init_height -= downSpeed
				if init_height >= desiredHeight:
					print(init_height, day_count)
					return day_count
					break


def growing_plant(upSpeed, downSpeed, desiredHeight):
	up = upSpeed
	i = 1
	while up < desiredHeight:
		up += upSpeed
		up -= downSpeed
		i += 1
	return i


def growing_plant(upSpeed, downSpeed, desiredHeight):
	growth = 0
	count = 1
	while growth < desiredHeight:
		growth += upSpeed
		if growth >= desiredHeight:
			return count
		count += 1
		growth -= downSpeed
	return count


def growing_plant(upSpeed, downSpeed, desiredHeight):
	(h, day) = (0, 1)
	while h != desiredHeight:
		h += upSpeed
		if h >= desiredHeight:
			break
		h -= downSpeed
		day += 1
	return day


def growing_plant(u, d, h):
	v = 0
	for i in range(1, int(1000.0)):
		v += u
		if v >= h:
			return i
		else:
			v -= d


def growing_plant(up, down, desired):
	height = up
	count = 1
	while height < desired:
		height = height + up - down
		count += 1
	return count