Skip to content

Commit

Permalink
# Simple Fun #74: Growing Plant
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent 11dd1fd commit b0e6da0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 66 deletions.
1 change: 1 addition & 0 deletions kyu_7/growing_plant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Simple Fun #74: Growing Plant."""
4 changes: 2 additions & 2 deletions kyu_7/growing_plant/growing_plant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Solution -> Simple Fun #74: Growing Plant
Solution -> Simple Fun #74: Growing Plant.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -12,7 +13,6 @@ def growing_plant(up_speed: int, down_speed: int, desired_height: int) -> int:
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.
:param up_speed: int
:param down_speed: int
:param desired_height: int
Expand Down
88 changes: 24 additions & 64 deletions kyu_7/growing_plant/test_growing_plant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test -> Simple Fun #74: Growing Plant
Test -> Simple Fun #74: Growing Plant.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_7.growing_plant.growing_plant import growing_plant

Expand All @@ -25,51 +27,19 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class GrowingPlantTestCase(unittest.TestCase):
"""
Testing growing_plant function
"""

def test_growing_plant(self):
"""Testing growing_plant function."""

@parameterized.expand([
((100, 10, 910), 10),
((10, 9, 4), 1),
((5, 2, 0), 1),
((5, 2, 5), 1),
((5, 2, 6), 2)])
def test_growing_plant(self, input_data, expected):
"""
Testing growing_plant function
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.
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).
Input/Output
Testing growing_plant function.
[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).
:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title('Testing growing_plant function')
Expand All @@ -82,23 +52,13 @@ def test_growing_plant(self):
"<p></p>")
# pylint: enable-msg=R0801
with allure.step('Enter upSpeed, downSpeed and '
'desiredHeight and verify the output'):
test_data: tuple = (
((100, 10, 910), 10),
((10, 9, 4), 1),
((5, 2, 0), 1),
((5, 2, 5), 1),
((5, 2, 6), 2))

for input_data, expected in test_data:
up_speed: int = input_data[0]
down_speed: int = input_data[1]
desired_height: int = input_data[2]

print_log(input_data=input_data,
expected=expected)

self.assertEqual(expected,
growing_plant(up_speed,
down_speed,
desired_height))
'desiredHeight and verify the output.'):
up_speed: int = input_data[0]
down_speed: int = input_data[1]
desired_height: int = input_data[2]
print_log(input_data=input_data,
expected=expected)
self.assertEqual(expected,
growing_plant(up_speed,
down_speed,
desired_height))

0 comments on commit b0e6da0

Please sign in to comment.