diff --git a/.github/workflows/pydocstyle_kyu8.yml b/.github/workflows/pydocstyle_kyu8.yml new file mode 100644 index 00000000000..0757b0c333b --- /dev/null +++ b/.github/workflows/pydocstyle_kyu8.yml @@ -0,0 +1,46 @@ +--- +name: pydocstyle for kyu8 + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'kyu8' + +permissions: + contents: read + pull-requests: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.x"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + # This is the version of the action for setting up Python, + # not the Python version. + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + # You can test your matrix by printing the current Python version + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + pip install -r requirements.txt + pip install pydocstyle + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Check pydocstyle version + run: | + pydocstyle --version + - name: Doc style checking with pydocstyle + # Pydocstyle testing (Guide) + # https://www.pydocstyle.org/en/stable/usage.html#cli-usage + run: | + pydocstyle --verbose --explain --count kyu_8 diff --git a/docs/kyu_8/kyu_8.closest_elevator.rst b/docs/kyu_8/kyu_8.closest_elevator.rst new file mode 100644 index 00000000000..87d8946ffa8 --- /dev/null +++ b/docs/kyu_8/kyu_8.closest_elevator.rst @@ -0,0 +1,32 @@ +kyu\_8.closest\_elevator package +================================ + +Submodules +---------- + +kyu\_8.closest\_elevator.closest\_elevator module +------------------------------------------------- + +.. automodule:: kyu_8.closest_elevator.closest_elevator + :members: + :undoc-members: + :show-inheritance: + :private-members: + +kyu\_8.closest\_elevator.test\_closest\_elevator module +------------------------------------------------------- + +.. automodule:: kyu_8.closest_elevator.test_closest_elevator + :members: + :undoc-members: + :show-inheritance: + :private-members: + +Module contents +--------------- + +.. automodule:: kyu_8.closest_elevator + :members: + :undoc-members: + :show-inheritance: + :private-members: diff --git a/docs/kyu_8/kyu_8.greek_sort.rst b/docs/kyu_8/kyu_8.greek_sort.rst index 8d34ffa8d2d..640c357c1c5 100644 --- a/docs/kyu_8/kyu_8.greek_sort.rst +++ b/docs/kyu_8/kyu_8.greek_sort.rst @@ -4,19 +4,19 @@ kyu\_8.greek\_sort package Submodules ---------- -kyu\_8.greek\_sort.greek\_comparator module -------------------------------------------- +kyu\_8.greek\_sort.evaluator module +----------------------------------- -.. automodule:: kyu_8.greek_sort.greek_comparator +.. automodule:: kyu_8.greek_sort.evaluator :members: :undoc-members: :show-inheritance: :private-members: -kyu\_8.greek\_sort.evaluator module +kyu\_8.greek\_sort.greek\_comparator module ------------------------------------------- -.. automodule:: kyu_8.greek_sort.evaluator +.. automodule:: kyu_8.greek_sort.greek_comparator :members: :undoc-members: :show-inheritance: diff --git a/docs/kyu_8/kyu_8.rst b/docs/kyu_8/kyu_8.rst index 4ebf3f9ed13..a144d283b9c 100644 --- a/docs/kyu_8/kyu_8.rst +++ b/docs/kyu_8/kyu_8.rst @@ -11,6 +11,7 @@ Subpackages kyu_8.alternating_case kyu_8.century_from_year kyu_8.check_the_exam + kyu_8.closest_elevator kyu_8.convert_string_to_an_array kyu_8.count_the_monkeys kyu_8.counting_sheep diff --git a/kyu_8/README.md b/kyu_8/README.md index 31f86dbec1c..739f1ecf7ce 100644 --- a/kyu_8/README.md +++ b/kyu_8/README.md @@ -15,44 +15,45 @@ harder the kata the faster you advance. ### List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| -|1 |[altERnaTIng cAsE <=> ALTerNAtiNG CaSe](https://www.codewars.com/kata/56efc695740d30f963000557) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/alternating_case) | -|2 |[Check the exam](https://www.codewars.com/kata/5a3dd29055519e23ec000074) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/check_the_exam) | -|3 |[Counting sheep...](https://www.codewars.com/kata/54edbc7200b811e956000556) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/counting_sheep) | -|4 |[Find the first non-consecutive number](https://www.codewars.com/kata/58f8a3a27a5c28d92e000144) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/find_the_first_non_consecutive_number)| -|5 |[Grasshopper - Check for Factor](https://www.codewars.com/kata/55cbc3586671f6aa070000fb) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_check_for_factor) | -|6 |[Grasshopper - Messi goals function](https://www.codewars.com/kata/55f73be6e12baaa5900000d4) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_messi_goals_function) | -|7 |[Grasshopper - Personalized Message](https://www.codewars.com/kata/5772da22b89313a4d50012f7) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_personalized_message) | -|8 |[Grasshopper - Summation](https://www.codewars.com/kata/55d24f55d7dd296eb9000030) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_summation) | -|9 |[Is it a palindrome](https://www.codewars.com/kata/57a1fd2ce298a731b20006a4) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/is_it_a_palindrome) | -|10 |[Is your period late](https://www.codewars.com/kata/578a8a01e9fd1549e50001f1) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/is_your_period_late) | -|11 |[Keep Hydrated!](https://www.codewars.com/kata/582cb0224e56e068d800003c) |[Solution](https://github.com/ikostan/codewars/blob/master/kyu_8/keep_hydrated/README.md) | -|12 |[Logical calculator](https://www.codewars.com/kata/57096af70dad013aa200007b) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/logical_calculator) | -|13 |[MakeUpperCase](https://www.codewars.com/kata/57a0556c7cb1f31ab3000ad7) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/make_upper_case) | -|14 |[Multiply](https://www.codewars.com/kata/50654ddff44f800200000004) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/multiply) | -|15 |[My head is at the wrong end](https://www.codewars.com/kata/56f699cd9400f5b7d8000b55) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/my_head_is_at_the_wrong_end) | -|16 |[Remove First and Last Character](https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/remove_first_and_last_character) | -|17 |[Remove String Spaces](https://www.codewars.com/kata/57eae20f5500ad98e50002c5) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/remove_string_spaces) | -|18 |[Reversed Strings](https://www.codewars.com/kata/5168bb5dfe9a00b126000018) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/reversed_strings) | -|19 |[L1: Set Alarm](https://www.codewars.com/kata/568dcc3c7f12767a62000038) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/set_alarm) | -|20 |[Surface Area and Volume of a Box](https://www.codewars.com/kata/565f5825379664a26b00007c) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/surface_area_and_volume_of_box) | -|21 |[Swap Values](https://www.codewars.com/kata/5388f0e00b24c5635e000fc6) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/swap_values) | -|22 |[Grasshopper - Terminal game move function](https://www.codewars.com/kata/563a631f7cbbc236cf0000c2) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/terminal_game_move_function) | -|23 |[Third Angle of a Triangle](https://www.codewars.com/kata/5a023c426975981341000014) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/third_angle_of_triangle) | -|24 |[Well of Ideas - Easy Version](https://www.codewars.com/kata/57f222ce69e09c3630000212) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/well_of_ideas_easy_version) | -|25 |[Will there be enough space](https://www.codewars.com/kata/5875b200d520904a04000003) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/will_there_be_enough_space) | -|26 |[A wolf in sheep's clothing](https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/wolf_in_sheep_clothing) | -|27 |[Formatting decimal places #0](https://www.codewars.com/kata/5641a03210e973055a00000d) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/formatting_decimal_places_0) | -|28 |[Convert a string to an array](https://www.codewars.com/kata/57e76bc428d6fbc2d500036d) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/convert_string_to_an_array) | -|29 |[The Feast of Many Beasts](https://www.codewars.com/kata/5aa736a455f906981800360d) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/the_feast_of_many_beasts) | -|30 |[Count the Monkeys!](https://www.codewars.com/kata/count-the-monkeys) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/count_the_monkeys) | -|31 |[Keep up the hoop](https://www.codewars.com/kata/55cb632c1a5d7b3ad0000145) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/keep_up_the_hoop) | -|32 |[Enumerable Magic #25 - Take the First N Elements](https://www.codewars.com/kata/545afd0761aa4c3055001386)|[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/enumerable_magic_25) | -|33 |[Will you make it?](https://www.codewars.com/kata/5861d28f124b35723e00005e) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/will_you_make_it) | -|34 |[Century From Year](https://www.codewars.com/kata/5a3fe3dde1ce0e8ed6000097) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/century_from_year) | -|35 |[Holiday VI - Shark Pontoon](https://www.codewars.com/kata/57e921d8b36340f1fd000059) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/holiday_vi_shark_pontoon) | -|36 |[My head is at the wrong end!](https://www.codewars.com/kata/56f699cd9400f5b7d8000b55) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/my_head_is_at_the_wrong_end) | -|37 |[Greek Sort](https://www.codewars.com/kata/56bc1acf66a2abc891000561) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/greek_sort) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:--------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------:| +| 1 | [altERnaTIng cAsE <=> ALTerNAtiNG CaSe](https://www.codewars.com/kata/56efc695740d30f963000557) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/alternating_case) | +| 2 | [Check the exam](https://www.codewars.com/kata/5a3dd29055519e23ec000074) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/check_the_exam) | +| 3 | [Counting sheep...](https://www.codewars.com/kata/54edbc7200b811e956000556) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/counting_sheep) | +| 4 | [Find the first non-consecutive number](https://www.codewars.com/kata/58f8a3a27a5c28d92e000144) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/find_the_first_non_consecutive_number) | +| 5 | [Grasshopper - Check for Factor](https://www.codewars.com/kata/55cbc3586671f6aa070000fb) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_check_for_factor) | +| 6 | [Grasshopper - Messi goals function](https://www.codewars.com/kata/55f73be6e12baaa5900000d4) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_messi_goals_function) | +| 7 | [Grasshopper - Personalized Message](https://www.codewars.com/kata/5772da22b89313a4d50012f7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_personalized_message) | +| 8 | [Grasshopper - Summation](https://www.codewars.com/kata/55d24f55d7dd296eb9000030) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/grasshopper_summation) | +| 9 | [Is it a palindrome](https://www.codewars.com/kata/57a1fd2ce298a731b20006a4) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/is_it_a_palindrome) | +| 10 | [Is your period late](https://www.codewars.com/kata/578a8a01e9fd1549e50001f1) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/is_your_period_late) | +| 11 | [Keep Hydrated!](https://www.codewars.com/kata/582cb0224e56e068d800003c) | [Solution](https://github.com/ikostan/codewars/blob/master/kyu_8/keep_hydrated/README.md) | +| 12 | [Logical calculator](https://www.codewars.com/kata/57096af70dad013aa200007b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/logical_calculator) | +| 13 | [MakeUpperCase](https://www.codewars.com/kata/57a0556c7cb1f31ab3000ad7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/make_upper_case) | +| 14 | [Multiply](https://www.codewars.com/kata/50654ddff44f800200000004) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/multiply) | +| 15 | [My head is at the wrong end](https://www.codewars.com/kata/56f699cd9400f5b7d8000b55) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/my_head_is_at_the_wrong_end) | +| 16 | [Remove First and Last Character](https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/remove_first_and_last_character) | +| 17 | [Remove String Spaces](https://www.codewars.com/kata/57eae20f5500ad98e50002c5) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/remove_string_spaces) | +| 18 | [Reversed Strings](https://www.codewars.com/kata/5168bb5dfe9a00b126000018) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/reversed_strings) | +| 19 | [L1: Set Alarm](https://www.codewars.com/kata/568dcc3c7f12767a62000038) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/set_alarm) | +| 20 | [Surface Area and Volume of a Box](https://www.codewars.com/kata/565f5825379664a26b00007c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/surface_area_and_volume_of_box) | +| 21 | [Swap Values](https://www.codewars.com/kata/5388f0e00b24c5635e000fc6) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/swap_values) | +| 22 | [Grasshopper - Terminal game move function](https://www.codewars.com/kata/563a631f7cbbc236cf0000c2) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/terminal_game_move_function) | +| 23 | [Third Angle of a Triangle](https://www.codewars.com/kata/5a023c426975981341000014) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/third_angle_of_triangle) | +| 24 | [Well of Ideas - Easy Version](https://www.codewars.com/kata/57f222ce69e09c3630000212) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/well_of_ideas_easy_version) | +| 25 | [Will there be enough space](https://www.codewars.com/kata/5875b200d520904a04000003) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/will_there_be_enough_space) | +| 26 | [A wolf in sheep's clothing](https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/wolf_in_sheep_clothing) | +| 27 | [Formatting decimal places #0](https://www.codewars.com/kata/5641a03210e973055a00000d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/formatting_decimal_places_0) | +| 28 | [Convert a string to an array](https://www.codewars.com/kata/57e76bc428d6fbc2d500036d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/convert_string_to_an_array) | +| 29 | [The Feast of Many Beasts](https://www.codewars.com/kata/5aa736a455f906981800360d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/the_feast_of_many_beasts) | +| 30 | [Count the Monkeys!](https://www.codewars.com/kata/count-the-monkeys) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/count_the_monkeys) | +| 31 | [Keep up the hoop](https://www.codewars.com/kata/55cb632c1a5d7b3ad0000145) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/keep_up_the_hoop) | +| 32 | [Enumerable Magic #25 - Take the First N Elements](https://www.codewars.com/kata/545afd0761aa4c3055001386) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/enumerable_magic_25) | +| 33 | [Will you make it?](https://www.codewars.com/kata/5861d28f124b35723e00005e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/will_you_make_it) | +| 34 | [Century From Year](https://www.codewars.com/kata/5a3fe3dde1ce0e8ed6000097) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/century_from_year) | +| 35 | [Holiday VI - Shark Pontoon](https://www.codewars.com/kata/57e921d8b36340f1fd000059) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/holiday_vi_shark_pontoon) | +| 36 | [My head is at the wrong end!](https://www.codewars.com/kata/56f699cd9400f5b7d8000b55) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/my_head_is_at_the_wrong_end) | +| 37 | [Greek Sort](https://www.codewars.com/kata/56bc1acf66a2abc891000561) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/greek_sort) | +| 38 | [Closest elevator](https://www.codewars.com/kata/5c374b346a5d0f77af500a5a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_8/closest_elevator) | [Source](https://www.codewars.com/about) diff --git a/kyu_8/__init__.py b/kyu_8/__init__.py index e69de29bb2d..3959b412ade 100644 --- a/kyu_8/__init__.py +++ b/kyu_8/__init__.py @@ -0,0 +1 @@ +"""8 kyu - Beginner package.""" diff --git a/kyu_8/alternating_case/__init__.py b/kyu_8/alternating_case/__init__.py index e69de29bb2d..4463be21191 100644 --- a/kyu_8/alternating_case/__init__.py +++ b/kyu_8/alternating_case/__init__.py @@ -0,0 +1 @@ +"""altERnaTIng cAsE <=> ALTerNAtiNG CaSe.""" diff --git a/kyu_8/alternating_case/alternating_case.py b/kyu_8/alternating_case/alternating_case.py index 06304da424b..f298b2e7c23 100644 --- a/kyu_8/alternating_case/alternating_case.py +++ b/kyu_8/alternating_case/alternating_case.py @@ -1,5 +1,6 @@ """ -altERnaTIng cAsE <=> ALTerNAtiNG CaSe +altERnaTIng cAsE <=> ALTerNAtiNG CaSe. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,9 +8,11 @@ def to_alternating_case(string: str) -> str: """ - each lowercase letter becomes uppercase and - each uppercase letter becomes lowercase - :param string: - :return: + Alternating case. + + Each lowercase letter becomes uppercase and + each uppercase letter becomes lowercase. + :param string: str + :return: str """ return ''.join((char.upper() if char.islower() else char.lower()) for char in string) diff --git a/kyu_8/alternating_case/test_alternating_case.py b/kyu_8/alternating_case/test_alternating_case.py index e11dc12b8e4..18fc1462444 100644 --- a/kyu_8/alternating_case/test_alternating_case.py +++ b/kyu_8/alternating_case/test_alternating_case.py @@ -1,5 +1,6 @@ """ -Testing for altERnaTIng cAsE <=> ALTerNAtiNG CaSe +Testing for altERnaTIng cAsE <=> ALTerNAtiNG CaSe. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.alternating_case.alternating_case \ import to_alternating_case @@ -26,13 +28,23 @@ name='Source/Kata') # pylint: enable=R0801 class AlternatingCaseTestCase(unittest.TestCase): - """ - Testing to_alternating_case function - """ + """Testing to_alternating_case function.""" - def test_alternating_case(self): + @parameterized.expand([ + ("hello world", "HELLO WORLD"), + ("HELLO WORLD", "hello world"), + ("HeLLo WoRLD", "hEllO wOrld"), + ("hello WORLD", "HELLO world"), + ("12345", "12345"), + ("1a2b3c4d5e", "1A2B3C4D5E"), + ("String.prototype.toAlternatingCase", + "sTRING.PROTOTYPE.TOaLTERNATINGcASE"), + ("Hello World", "hELLO wORLD"), + ("altERnaTIng cAsE", "ALTerNAtiNG CaSe")]) + def test_alternating_case(self, string, expected): """ - Testing to_alternating_case function + Testing to_alternating_case function with various test data. + :return: """ # pylint: disable=R0801 @@ -40,26 +52,13 @@ def test_alternating_case(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '
Given a year, the function should return the century it is in." + "
Given a year, the function should return " + "the century it is in." "
") # pylint: enable-msg=R0801 - test_data: tuple = ( - (1705, 18, 'Testing for year 1705'), - (1900, 19, 'Testing for year 1900'), - (1601, 17, 'Testing for year 1601'), - (2000, 20, 'Testing for year 2000'), - (356, 4, 'Testing for year 356'), - (89, 1, 'Testing for year 89')) - - for year, expected, message in test_data: - result: int = century(year) - - with allure.step(f"Enter test year ({year}) and verify " - f"the output ({result}) " - f"vs expected ({expected})"): - - print_log(year=year, - result=result, - expected=expected, - message=message) - - self.assertEqual(expected, - result) + result: int = century(year) + with allure.step(f"Enter test year ({year}) and verify " + f"the output ({result}) " + f"vs expected ({expected})"): + print_log(year=year, + result=result, + expected=expected, + message=message) + self.assertEqual(expected, result) diff --git a/kyu_8/check_the_exam/__init__.py b/kyu_8/check_the_exam/__init__.py index e69de29bb2d..b61f6186057 100644 --- a/kyu_8/check_the_exam/__init__.py +++ b/kyu_8/check_the_exam/__init__.py @@ -0,0 +1 @@ +"""Check the exam.""" diff --git a/kyu_8/check_the_exam/check_exam.py b/kyu_8/check_the_exam/check_exam.py index 319bf5d155f..cf3d0a93805 100644 --- a/kyu_8/check_the_exam/check_exam.py +++ b/kyu_8/check_the_exam/check_exam.py @@ -1,5 +1,6 @@ """ -Solution for -> Check the exam +Solution for -> Check the exam. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def check_exam(arr1: list, arr2: list) -> int: """ + Check exam. + The first input array contains the correct answers to an exam, like ["a", "a", "b", "d"]. The second one is "answers" array and contains student's answers. @@ -32,7 +35,8 @@ def check_exam(arr1: list, arr2: list) -> int: def char_processor(char: tuple, results: list) -> None: """ - Processing chars based on specified rule + Process chars based on specified rule. + :param char: str :param results: list :return: None diff --git a/kyu_8/check_the_exam/test_check_exam.py b/kyu_8/check_the_exam/test_check_exam.py index 8fc45f2098b..ad27e93914a 100644 --- a/kyu_8/check_the_exam/test_check_exam.py +++ b/kyu_8/check_the_exam/test_check_exam.py @@ -1,5 +1,6 @@ """ -Test for -> Check the exam +Test for -> Check the exam. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.check_the_exam.check_exam import check_exam @@ -28,20 +30,21 @@ name='Source/Kata') # pylint: enable=R0801 class CheckExamTestCase(unittest.TestCase): - """ - Testing check_exam function - """ - - def test_check_exam(self): + """Testing check_exam function.""" + + @parameterized.expand([ + (["a", "a", "b", "b"], ["a", "c", "b", "d"], 6), + (["a", "a", "c", "b"], ["a", "a", "b", ""], 7), + (["a", "a", "b", "c"], ["a", "a", "b", "c"], 16), + (["b", "c", "b", "a"], ["", "a", "a", "c"], 0)]) + def test_check_exam(self, arr1, arr2, expected): """ - Testing check_exam function + Testing check_exam function with various test data. - The function should return the score - for this array of answers, giving +4 - for each correct answer, -1 for each - incorrect answer, and +0 for each blank + The function should return the score for this + array of answers, giving +4 for each correct answer, + -1 for each incorrect answer, and +0 for each blank answer(empty string). - :return: """ # pylint: disable=R0801 @@ -49,22 +52,12 @@ def test_check_exam(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'Create a method take that accepts a list/array and a" " number n, and returns a list/array array of the first " @@ -49,31 +56,14 @@ def test_take(self): "https://docs.python.org/3/library/stdtypes" ".html#sequence-types-list-tuple-range
") # pylint: enable=R0801 - test_data: tuple = ( - ([0, 1, 2, 3, 5, 8, 13], - 3, - [0, 1, 2]), - ([51], - 35, - [51]), - ([], - 3, - []), - ([0, 1, 2, 3, 5, 8, 13], - 0, - [])) - - for arr, n, expected in test_data: - actual_result = take(arr, n) - - with allure.step(f"Enter a list ({arr}) and verify the " - f"expected output ({expected}) " - f"vs actual result ({actual_result})"): + actual_result = take(arr, n) + with allure.step(f"Enter a list ({arr}) and verify the " + f"expected output ({expected}) " + f"vs actual result ({actual_result})"): - print_log(rr=arr, + print_log(rr=arr, n=n, expected=expected, result=actual_result) - self.assertEqual(expected, - actual_result) + self.assertEqual(expected, actual_result) diff --git a/kyu_8/find_the_first_non_consecutive_number/__init__.py b/kyu_8/find_the_first_non_consecutive_number/__init__.py index e69de29bb2d..97e0a5e54d6 100644 --- a/kyu_8/find_the_first_non_consecutive_number/__init__.py +++ b/kyu_8/find_the_first_non_consecutive_number/__init__.py @@ -0,0 +1 @@ +"""Find the first non-consecutive number.""" diff --git a/kyu_8/find_the_first_non_consecutive_number/first_non_consecutive.py b/kyu_8/find_the_first_non_consecutive_number/first_non_consecutive.py index e88d5a1c966..0c21f38cd62 100644 --- a/kyu_8/find_the_first_non_consecutive_number/first_non_consecutive.py +++ b/kyu_8/find_the_first_non_consecutive_number/first_non_consecutive.py @@ -1,5 +1,6 @@ """ -Solution for -> Find the first non-consecutive number +Solution for -> Find the first non-consecutive number. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_8/find_the_first_non_consecutive_number/test_first_non_consecutive.py b/kyu_8/find_the_first_non_consecutive_number/test_first_non_consecutive.py index fe89221e5a2..ff9c7a69abb 100644 --- a/kyu_8/find_the_first_non_consecutive_number/test_first_non_consecutive.py +++ b/kyu_8/find_the_first_non_consecutive_number/test_first_non_consecutive.py @@ -1,5 +1,6 @@ """ -Test for -> Find the first non-consecutive number +Test for -> Find the first non-consecutive number. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,12 +28,12 @@ name='Source/Kata') # pylint: enable=R0801 class FirstNonConsecutiveTestCase(unittest.TestCase): - """ - Testing first_non_consecutive function - """ + """Testing first_non_consecutive function.""" def test_first_non_consecutive_none(self): """ + Testing first_non_consecutive function, non-consecutive numbers. + If the whole array is consecutive then return null or Nothing or None. :return: @@ -42,12 +43,13 @@ def test_first_non_consecutive_none(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'A custom comparison function of two arguments (iterable" " elements) which should return a negative, zero or positive" @@ -48,26 +53,17 @@ def test_greek_comparator(self): " smaller than, equal to, or larger than the second argument" "
") # pylint: enable=R0801 - test_data: tuple = ( - ('alpha', 'beta', '< 0'), - ('psi', 'psi', '== 0'), - ('upsilon', 'rho', '> 0')) - - for d in test_data: - lhs, rhs, expected = d[0], d[1], d[2] - result = greek_comparator(lhs, rhs) - - with allure.step(f"Enter test inputs({lhs}, {rhs}) " - f"and assert expected ({expected}) " - f"vs actual result ({result})"): + result = greek_comparator(lhs, rhs) + with allure.step(f"Enter test inputs({lhs}, {rhs}) " + f"and assert expected ({expected}) " + f"vs actual result ({result})"): - expression: str = f'{result} {expected}' + expression: str = f'{result} {expected}' - print_log(lhs=lhs, - rhs=rhs, - expected=expected, - result=result, - expression=expression) + print_log(lhs=lhs, + rhs=rhs, + expected=expected, + result=result, + expression=expression) - self.assertTrue(evaluator(result=result, - expected=expected)) + self.assertTrue(evaluator(result=result, expected=expected)) diff --git a/kyu_8/holiday_vi_shark_pontoon/__init__.py b/kyu_8/holiday_vi_shark_pontoon/__init__.py index e69de29bb2d..d2ec6b21e8c 100644 --- a/kyu_8/holiday_vi_shark_pontoon/__init__.py +++ b/kyu_8/holiday_vi_shark_pontoon/__init__.py @@ -0,0 +1 @@ +"""Holiday VI - Shark Pontoon.""" diff --git a/kyu_8/holiday_vi_shark_pontoon/shark.py b/kyu_8/holiday_vi_shark_pontoon/shark.py index c1b97b07c7b..2decb2b5b55 100644 --- a/kyu_8/holiday_vi_shark_pontoon/shark.py +++ b/kyu_8/holiday_vi_shark_pontoon/shark.py @@ -1,5 +1,6 @@ """ -Solution for -> Holiday VI - Shark Pontoon +Solution for -> Holiday VI - Shark Pontoon. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -11,6 +12,8 @@ def shark(pontoon_distance, shark_speed, dolphin) -> str: """ + Shark function. + You are given 5 variables: sharkDistance = distance the shark needs to cover to eat you in metres, sharkSpeed = how fast it can move in metres/second, pontoonDistance = how far you need @@ -19,7 +22,6 @@ def shark(pontoon_distance, the swimming speed of the shark as the dolphin will attack it. If you make it, return "Alive!", if not, return "Shark Bait!". - :param pontoon_distance: :param shark_distance: :param you_speed: diff --git a/kyu_8/holiday_vi_shark_pontoon/test_shark.py b/kyu_8/holiday_vi_shark_pontoon/test_shark.py index 712bc97e21c..350946571f7 100644 --- a/kyu_8/holiday_vi_shark_pontoon/test_shark.py +++ b/kyu_8/holiday_vi_shark_pontoon/test_shark.py @@ -1,5 +1,6 @@ """ -Test for -> Holiday VI - Shark Pontoon +Test for -> Holiday VI - Shark Pontoon. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,13 +27,12 @@ url='https://www.codewars.com/kata/57e921d8b36340f1fd000059', name='Source/Kata') class SharkTestCase(unittest.TestCase): - """ - Testing shark function - """ + """Testing shark function.""" def test_shark_alive_1(self): """ - Testing shark function -> positive + Testing shark function -> positive #1. + :return: """ # pylint: disable=R0801 @@ -66,7 +66,8 @@ def test_shark_alive_1(self): def test_shark_alive_2(self): """ - Testing shark function -> positive + Testing shark function -> positive #2. + :return: """ # pylint: disable=R0801 @@ -100,7 +101,8 @@ def test_shark_alive_2(self): def test_shark_bait(self): """ - Testing shark function -> negative + Testing shark function -> negative. + :return: """ # pylint: disable=R0801 diff --git a/kyu_8/is_it_a_palindrome/__init__.py b/kyu_8/is_it_a_palindrome/__init__.py index e69de29bb2d..d96511f544b 100644 --- a/kyu_8/is_it_a_palindrome/__init__.py +++ b/kyu_8/is_it_a_palindrome/__init__.py @@ -0,0 +1 @@ +"""Is it a palindrome.""" diff --git a/kyu_8/is_it_a_palindrome/is_palindrome.py b/kyu_8/is_it_a_palindrome/is_palindrome.py index 0e0afcb961b..88ba9606d18 100644 --- a/kyu_8/is_it_a_palindrome/is_palindrome.py +++ b/kyu_8/is_it_a_palindrome/is_palindrome.py @@ -1,5 +1,6 @@ """ -Solution for -> Is it a palindrome? +Solution for -> Is it a palindrome?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,10 @@ def is_palindrome(s: str) -> bool: """ + Palindrome testing function. + Write function isPalindrome that checks if - a given string (case insensitive) is a palindrome. + a given string (case-insensitive) is a palindrome. :param s: str :return: bool """ diff --git a/kyu_8/is_it_a_palindrome/test_is_palindrome.py b/kyu_8/is_it_a_palindrome/test_is_palindrome.py index 71fea953daf..5d28ea002fe 100644 --- a/kyu_8/is_it_a_palindrome/test_is_palindrome.py +++ b/kyu_8/is_it_a_palindrome/test_is_palindrome.py @@ -1,5 +1,6 @@ """ -Test for -> Is it a palindrome? +Test for -> Is it a palindrome?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.is_it_a_palindrome.is_palindrome import is_palindrome @@ -25,18 +27,28 @@ name='Source/Kata') # pylint: enable=R0801 class IsPalindromeTestCase(unittest.TestCase): - """ - Testing is_palindrome function - """ + """Testing is_palindrome function.""" - def test_is_palindrome(self): + @parameterized.expand([ + ('a', True), + ('aba', True), + ('Abba', True), + ('malam', True), + ('walter', False), + ('kodok', True), + ('Kasue', False), + ('NdjXglGnYGKhQtuAcxNWFwVRZZDMrFmiOPMZsvr', False), + ('XqmUTaAmrrYitgNwkCwaWdFYsEhfIeOohViba', False), + ('ZtItThFBUPCSCbtcUfDwXzyajhRIWioUHpVzN', False), + ('XqNeuBjbshHwqjoUNGHhVRolqxWRRWYYbN', False)]) + def test_is_palindrome(self, string, expected): """ - Testing is_palindrome function - with various test inputs + Testing is_palindrome function with various test inputs. The function should check if a - given string (case insensitive) + given string (case-insensitive) is a palindrome. + :return: """ # pylint: disable=R0801 allure.dynamic.title("Testing is_palindrome function") @@ -46,22 +58,10 @@ def test_is_palindrome(self): '' 'isPalindrome that checks if a given string " + "(case insensitive) is a palindrome.
") - for string, expected in test_data: - print_log(string=string, expected=expected) - self.assertEqual(expected, is_palindrome(string)) + with allure.step(f"Enter test string: {string} " + f"and verify expected output: {expected}."): + print_log(string=string, expected=expected) + self.assertEqual(expected, is_palindrome(string)) diff --git a/kyu_8/is_your_period_late/__init__.py b/kyu_8/is_your_period_late/__init__.py index e69de29bb2d..0328c3963b9 100644 --- a/kyu_8/is_your_period_late/__init__.py +++ b/kyu_8/is_your_period_late/__init__.py @@ -0,0 +1 @@ +"""Is your period late.""" diff --git a/kyu_8/is_your_period_late/is_your_period_late.py b/kyu_8/is_your_period_late/is_your_period_late.py index 122f68b50c8..c310e5f4213 100644 --- a/kyu_8/is_your_period_late/is_your_period_late.py +++ b/kyu_8/is_your_period_late/is_your_period_late.py @@ -1,5 +1,6 @@ """ -Solution for -> Is your period late +Solution for -> Is your period late. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_8/is_your_period_late/test_is_your_period_late.py b/kyu_8/is_your_period_late/test_is_your_period_late.py index eb75b23032f..b47b73b21f7 100644 --- a/kyu_8/is_your_period_late/test_is_your_period_late.py +++ b/kyu_8/is_your_period_late/test_is_your_period_late.py @@ -1,5 +1,6 @@ """ -Test for -> Is your period late +Test for -> Is your period late. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,13 +28,12 @@ name='Source/Kata') # pylint: enable=R0801 class PeriodIsLateTestCase(unittest.TestCase): - """ - Testing period_is_late function - """ + """Testing period_is_late function.""" def test_period_is_late_positive(self): """ - Positive tests + Positive tests. + :return: """ # pylint: disable=R0801 @@ -44,7 +44,7 @@ def test_period_is_late_positive(self): '' 'Positive tests.
") # pylint: enable=R0801 with allure.step("Pass last, today and period length"): last: date = date(2016, 6, 13) @@ -96,7 +96,8 @@ def test_period_is_late_positive(self): def test_period_is_late_negative(self): """ - Negative tests + Negative tests. + :return: """ # pylint: disable=R0801 @@ -107,7 +108,7 @@ def test_period_is_late_negative(self): '' 'Negative tests.
") # pylint: enable=R0801 with allure.step("Pass last, today and period length"): last: date = date(2016, 6, 13) diff --git a/kyu_8/keep_hydrated/__init__.py b/kyu_8/keep_hydrated/__init__.py index e69de29bb2d..7240da1b8cc 100644 --- a/kyu_8/keep_hydrated/__init__.py +++ b/kyu_8/keep_hydrated/__init__.py @@ -0,0 +1 @@ +"""Keep Hydrated.""" diff --git a/kyu_8/keep_hydrated/keep_hydrated.py b/kyu_8/keep_hydrated/keep_hydrated.py index 454ab57d457..a1bf20807cb 100644 --- a/kyu_8/keep_hydrated/keep_hydrated.py +++ b/kyu_8/keep_hydrated/keep_hydrated.py @@ -1,5 +1,6 @@ """ -Solution for -> Keep Hydrated! +Solution for -> Keep Hydrated!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def litres(time) -> int: """ + 'litres' function. + Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. diff --git a/kyu_8/keep_hydrated/test_keep_hydrated.py b/kyu_8/keep_hydrated/test_keep_hydrated.py index e8e64b29b50..54f73cc6f56 100644 --- a/kyu_8/keep_hydrated/test_keep_hydrated.py +++ b/kyu_8/keep_hydrated/test_keep_hydrated.py @@ -1,5 +1,6 @@ """ -Test for -> Keep Hydrated! +Test for -> Keep Hydrated!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.keep_hydrated.keep_hydrated import litres @@ -28,13 +30,20 @@ name='Source/Kata') # pylint: disable=R0801 class KeepHydratedTestCase(unittest.TestCase): - """ - Testing litres function - """ + """Testing litres function.""" - def test_keep_hydrated(self): + @parameterized.expand([ + (2, 1, 'should return 1 litre'), + (1.4, 0, 'should return 0 litres'), + (12.3, 6, 'should return 6 litres'), + (0.82, 0, 'should return 0 litres'), + (11.8, 5, 'should return 5 litres'), + (1787, 893, 'should return 893 litres'), + (0, 0, 'should return 0 litres')]) + def test_keep_hydrated(self, hours, expected, message): """ - Testing litres function with various test inputs + Testing litres function with various test inputs. + :return: """ # pylint: disable=R0801 @@ -45,18 +54,17 @@ def test_keep_hydrated(self): '' '" + "Because Nathan knows it is important to stay hydrated, " + " he drinks 0.5 litres of water per hour of cycling." + "
" + "" + "You get given the time in hours and you need to return " + "the number of litres Nathan will drink, rounded " + "to the smallest value." + "
") # pylint: enable=R0801 - with allure.step("Enter hours and verify the output"): - test_data: tuple = ( - (2, 1, 'should return 1 litre'), - (1.4, 0, 'should return 0 litres'), - (12.3, 6, 'should return 6 litres'), - (0.82, 0, 'should return 0 litres'), - (11.8, 5, 'should return 5 litres'), - (1787, 893, 'should return 893 litres'), - (0, 0, 'should return 0 litres')) - - for hours, expected, message in test_data: - print_log(hours=hours, expected=expected) - self.assertEqual(expected, litres(hours), message) + with allure.step(f"Enter hours: {hours} " + f"and verify the expected output: {expected}."): + print_log(hours=hours, expected=expected) + self.assertEqual(expected, litres(hours), message) diff --git a/kyu_8/keep_up_the_hoop/__init__.py b/kyu_8/keep_up_the_hoop/__init__.py index e69de29bb2d..c1749419584 100644 --- a/kyu_8/keep_up_the_hoop/__init__.py +++ b/kyu_8/keep_up_the_hoop/__init__.py @@ -0,0 +1 @@ +"""Keep up the hoop.""" diff --git a/kyu_8/keep_up_the_hoop/hoop_count.py b/kyu_8/keep_up_the_hoop/hoop_count.py index bff4cedf9a5..9badc57f057 100644 --- a/kyu_8/keep_up_the_hoop/hoop_count.py +++ b/kyu_8/keep_up_the_hoop/hoop_count.py @@ -1,5 +1,6 @@ """ -Solution -> Keep up the hoop +Solution -> Keep up the hoop. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,9 +8,10 @@ def hoop_count(n: int) -> str: """ - A program where Alex can input (n) how many times the - hoop goes round and it will return him an encouraging message + 'hoop_count' function. + A program where Alex can input (n) how many times the + hoop goes round, and it will return him an encouraging message :param n: int :return: str """ diff --git a/kyu_8/keep_up_the_hoop/test_hoop_count.py b/kyu_8/keep_up_the_hoop/test_hoop_count.py index ee377488e2d..fa5ae53c944 100644 --- a/kyu_8/keep_up_the_hoop/test_hoop_count.py +++ b/kyu_8/keep_up_the_hoop/test_hoop_count.py @@ -1,5 +1,6 @@ """ -Test -> Keep up the hoop +Test -> Keep up the hoop. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,22 +26,19 @@ name='Source/Kata') # pylint: enable=R0801 class HoopCountTestCase(unittest.TestCase): - """ - Testing hoop_count function - """ + """Testing hoop_count function.""" def test_hoop_count_positive(self): """ - Testing hoop_count function (positive) + Testing hoop_count function (positive). - Alex just got a new hula hoop, he loves it but feels + Alex just got a new hula-hoop, he loves it but feels discouraged because his little brother is better than him Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message - 10 or more hoops, return "Great, now move on to tricks". - - Not 10 hoops, return "Keep at it until you get it". :return: @@ -54,7 +52,7 @@ def test_hoop_count_positive(self): '' 'Testing hoop_count function (positive).
") # pylint: enable=R0801 with allure.step("Enter n and verify the result"): n: int = 11 @@ -64,7 +62,8 @@ def test_hoop_count_positive(self): def test_hoop_count_negative(self): """ - Testing hoop_count function (negative) + Testing hoop_count function (negative). + :return: """ # pylint: disable=R0801 @@ -76,7 +75,7 @@ def test_hoop_count_negative(self): '' 'Testing hoop_count function (negative).
") # pylint: enable=R0801 with allure.step("Enter n and verify the result"): n: int = 3 diff --git a/kyu_8/logical_calculator/__init__.py b/kyu_8/logical_calculator/__init__.py index e69de29bb2d..ef9d65f99ea 100644 --- a/kyu_8/logical_calculator/__init__.py +++ b/kyu_8/logical_calculator/__init__.py @@ -0,0 +1 @@ +"""Logical calculator.""" diff --git a/kyu_8/logical_calculator/logical_calculator.py b/kyu_8/logical_calculator/logical_calculator.py index 4bcf26788e6..39cfbe75614 100644 --- a/kyu_8/logical_calculator/logical_calculator.py +++ b/kyu_8/logical_calculator/logical_calculator.py @@ -1,5 +1,6 @@ """ -Solution for -> Logical Calculator +Solution for -> Logical Calculator. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,7 @@ def logical_calc(array: list, op: str) -> bool: """ - Calculates logical value of boolean array. + Calculate logical value of boolean array. Logical operations: AND, OR and XOR. diff --git a/kyu_8/logical_calculator/test_logical_calculator.py b/kyu_8/logical_calculator/test_logical_calculator.py index 7f4e11cc220..875e0f8bfa1 100644 --- a/kyu_8/logical_calculator/test_logical_calculator.py +++ b/kyu_8/logical_calculator/test_logical_calculator.py @@ -1,5 +1,6 @@ """ -Test for -> Logical Calculator +Test for -> Logical Calculator. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,21 +28,17 @@ name='Source/Kata') # pylint: enable=R0801 class LogicalCalculatorTestCase(unittest.TestCase): - """ - Testing logical_calc function - """ + """Testing logical_calc function.""" def test_logical_calc_and(self): """ - And (∧) is the truth-functional - operator of logical conjunction + And (∧) is the truth-functional operator of logical conjunction. - The and of a set of operands is true + The 'and' of a set of operands is true if and only if all of its operands are true. Source: https://en.wikipedia.org/wiki/Logical_conjunction - :return: """ # pylint: disable=R0801 @@ -49,10 +46,13 @@ def test_logical_calc_and(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'The 'and' of a set of operands is true " + "if and only if all of its operands are true." + "
") # pylint: enable=R0801 with allure.step("Pass an array with 2 members (negative)"): lst: list = [True, False] @@ -97,11 +97,13 @@ def test_logical_calc_and(self): def test_logical_calc_or(self): """ + Testing 'or'. + In logic and mathematics, or is the truth-functional operator of (inclusive) disjunction, also known as alternation. - The or of a set of operands is true if + The 'or' of a set of operands is true if and only if one or more of its operands is true. Source: @@ -117,7 +119,10 @@ def test_logical_calc_or(self): '' '" + "The 'or' of a set of operands is true if " + "and only if one or more of its operands is true." + "
") # pylint: enable=R0801 with allure.step('Pass an array with 2 members (positive)'): lst: list = [True, False] @@ -155,7 +160,9 @@ def test_logical_calc_or(self): def test_logical_calc_xor(self): """ - Exclusive or or exclusive disjunction is a + Testing 'XOR'. + + Exclusive or exclusive disjunction is a logical operation that outputs true only when inputs differ (one is true, the other is false). @@ -170,10 +177,11 @@ def test_logical_calc_xor(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'XOR outputs true whenever the inputs differ.
") # pylint: enable=R0801 with allure.step('Pass an array with 2 members (positive)'): lst: list = [True, False] diff --git a/kyu_8/make_upper_case/__init__.py b/kyu_8/make_upper_case/__init__.py index e69de29bb2d..f1eedc12b18 100644 --- a/kyu_8/make_upper_case/__init__.py +++ b/kyu_8/make_upper_case/__init__.py @@ -0,0 +1 @@ +"""MakeUpperCase.""" diff --git a/kyu_8/make_upper_case/make_upper_case.py b/kyu_8/make_upper_case/make_upper_case.py index bdf110549ba..b2dd792edbb 100644 --- a/kyu_8/make_upper_case/make_upper_case.py +++ b/kyu_8/make_upper_case/make_upper_case.py @@ -1,5 +1,6 @@ """ -Solution for -> MakeUpperCase +Solution for -> MakeUpperCase. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,8 @@ def make_upper_case(s: str) -> str: """ - Function that make UpperCase. + Convert to UpperCase. + :param s: str :return: str """ diff --git a/kyu_8/make_upper_case/test_make_upper_case.py b/kyu_8/make_upper_case/test_make_upper_case.py index 8b4e69f812f..e91e66ce0e9 100644 --- a/kyu_8/make_upper_case/test_make_upper_case.py +++ b/kyu_8/make_upper_case/test_make_upper_case.py @@ -1,5 +1,6 @@ """ -Test for -> MakeUpperCase +Test for -> MakeUpperCase. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,13 +26,12 @@ name='Source/Kata') # pylint: enable=R0801 class MakeUpperCaseTestCase(unittest.TestCase): - """ - Testing make_upper_case function - """ + """Testing make_upper_case function.""" def test_make_upper_case(self): """ - Sample Tests for make_upper_case function + Sample Tests for make_upper_case function. + :return: """ # pylint: disable=R0801 @@ -39,10 +39,12 @@ def test_make_upper_case(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'Make sure 'make_upper_case' function convert " + "strings to UpperCase.
") # pylint: enable=R0801 with allure.step("Pass lower case string and verify the output"): string: str = "hello" diff --git a/kyu_8/multiply/__init__.py b/kyu_8/multiply/__init__.py index e69de29bb2d..b14368ed6b5 100644 --- a/kyu_8/multiply/__init__.py +++ b/kyu_8/multiply/__init__.py @@ -0,0 +1 @@ +"""Multiply.""" diff --git a/kyu_8/multiply/multiply.py b/kyu_8/multiply/multiply.py index 2ee767034da..d229bbee71a 100644 --- a/kyu_8/multiply/multiply.py +++ b/kyu_8/multiply/multiply.py @@ -1,9 +1,5 @@ """ -Multiply Problem Description -The code does not execute properly. Try to figure out why. - -def multiply(a, b): - a * b +Solution for -> Multiply problem. Created by Egor Kostan. GitHub: https://github.com/ikostan @@ -12,9 +8,10 @@ def multiply(a, b): def multiply(a: int, b: int) -> int: """ - Multiply two numbers and return the result - :param a: - :param b: - :return: + Multiply two numbers and return the result. + + :param a: int + :param b: int + :return: int """ return a * b diff --git a/kyu_8/multiply/test_multiply.py b/kyu_8/multiply/test_multiply.py index ad3ad6eacd0..b88e820f674 100644 --- a/kyu_8/multiply/test_multiply.py +++ b/kyu_8/multiply/test_multiply.py @@ -1,5 +1,6 @@ """ -Test for -> Multiply +Test for -> Multiply. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,14 +27,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class MultiplyTestCase(unittest.TestCase): - """ - Testing multiply function - """ + """Testing multiply function.""" def test_multiply(self): """ - Verify that multiply function - returns correct result + Verify that multiply function returns correct results. + :return: """ # pylint: disable-msg=R0801 diff --git a/kyu_8/my_head_is_at_the_wrong_end/__init__.py b/kyu_8/my_head_is_at_the_wrong_end/__init__.py index e69de29bb2d..3e664a34072 100644 --- a/kyu_8/my_head_is_at_the_wrong_end/__init__.py +++ b/kyu_8/my_head_is_at_the_wrong_end/__init__.py @@ -0,0 +1 @@ +"""My head is at the wrong end.""" diff --git a/kyu_8/my_head_is_at_the_wrong_end/fix_the_meerkat.py b/kyu_8/my_head_is_at_the_wrong_end/fix_the_meerkat.py index e8712249bf6..2fd21c771ca 100644 --- a/kyu_8/my_head_is_at_the_wrong_end/fix_the_meerkat.py +++ b/kyu_8/my_head_is_at_the_wrong_end/fix_the_meerkat.py @@ -1,5 +1,6 @@ """ -Solution for -> My head is at the wrong end! +Solution for -> My head is at the wrong end!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,11 +8,9 @@ def fix_the_meerkat(arr: list) -> list: """ - You will be given an array which will have - three values (tail, body, head). - It is your job to re-arrange the array so - that the animal is the right way round - (head, body, tail). + 'fix_the_meerkat' function. + + Reversing a List in Python. :param arr: :return: """ diff --git a/kyu_8/my_head_is_at_the_wrong_end/test_fix_the_meerkat.py b/kyu_8/my_head_is_at_the_wrong_end/test_fix_the_meerkat.py index 66331140cb1..92fedecf622 100644 --- a/kyu_8/my_head_is_at_the_wrong_end/test_fix_the_meerkat.py +++ b/kyu_8/my_head_is_at_the_wrong_end/test_fix_the_meerkat.py @@ -1,5 +1,6 @@ """ -Test for -> My head is at the wrong end! +Test for -> My head is at the wrong end!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.my_head_is_at_the_wrong_end.fix_the_meerkat \ import fix_the_meerkat @@ -30,13 +32,24 @@ # pylint: enable=R0801 # @pytest.mark.skip(reason="The solution is not ready") class FixTheMeerkatTestCase(unittest.TestCase): - """ - Testing fix_the_meerkat function - """ + """Testing fix_the_meerkat function.""" - def test_fix_the_meerkat(self): + @parameterized.expand([ + (["tail", "body", "head"], ["head", "body", "tail"]), + (["tails", "body", "heads"], ["heads", "body", "tails"]), + (["bottom", "middle", "top"], ["top", "middle", "bottom"]), + (["lower legs", "torso", "upper legs"], + ["upper legs", "torso", "lower legs"]), + (["ground", "rainbow", "sky"], ["sky", "rainbow", "ground"])]) + def test_fix_the_meerkat(self, arr, expected): """ - Testing fix_the_meerkat function with various test data + Testing fix_the_meerkat function with various test data. + + You will be given an array which will have + three values (tail, body, head). + It is your job to re-arrange the array so + that the animal is the right way round + (head, body, tail). :return: """ # pylint: disable=R0801 @@ -54,21 +67,9 @@ def test_fix_the_meerkat(self): "so that the animal is the right way round (head, body, tail)." "") # pylint: disable=R0801 - test_data: tuple = ( - (["tail", "body", "head"], ["head", "body", "tail"]), - (["tails", "body", "heads"], ["heads", "body", "tails"]), - (["bottom", "middle", "top"], ["top", "middle", "bottom"]), - (["lower legs", "torso", "upper legs"], - ["upper legs", "torso", "lower legs"]), - (["ground", "rainbow", "sky"], ["sky", "rainbow", "ground"])) - - for data in test_data: - arr: list = data[0] - expected: list = data[1] - result: list = fix_the_meerkat(arr) - - with allure.step(f"Enter test data: {arr} " - f"and assert actual result: {result} " - f"vs expected: {expected}"): - print_log(arr=arr, result=result, expected=expected) - self.assertEqual(expected, result) + result: list = fix_the_meerkat(arr) + with allure.step(f"Enter test data: {arr} " + f"and assert actual result: {result} " + f"vs expected: {expected}"): + print_log(arr=arr, result=result, expected=expected) + self.assertEqual(expected, result) diff --git a/kyu_8/remove_first_and_last_character/__init__.py b/kyu_8/remove_first_and_last_character/__init__.py index e69de29bb2d..d4dad132afd 100644 --- a/kyu_8/remove_first_and_last_character/__init__.py +++ b/kyu_8/remove_first_and_last_character/__init__.py @@ -0,0 +1 @@ +"""Remove First and Last Character.""" diff --git a/kyu_8/remove_first_and_last_character/remove_char.py b/kyu_8/remove_first_and_last_character/remove_char.py index 305ad603678..4f9f7de5c68 100644 --- a/kyu_8/remove_first_and_last_character/remove_char.py +++ b/kyu_8/remove_first_and_last_character/remove_char.py @@ -1,5 +1,6 @@ """ -Solution for -> Remove First and Last Character +Solution for -> Remove First and Last Character. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,13 +8,10 @@ def remove_char(s: str) -> str: """ - A function that removes the first and - last characters of a string. + Remove the first and last characters of a string. You're given one parameter, the original string. - - You don't have to worry with strings - with less than two characters. + You don't have to worry with strings with less than two characters. :param s: str :return: str """ diff --git a/kyu_8/remove_first_and_last_character/test_remove_char.py b/kyu_8/remove_first_and_last_character/test_remove_char.py index 104e80bb659..660a6480b51 100644 --- a/kyu_8/remove_first_and_last_character/test_remove_char.py +++ b/kyu_8/remove_first_and_last_character/test_remove_char.py @@ -1,5 +1,6 @@ """ -Test for -> Remove First and Last Character +Test for -> Remove First and Last Character. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -28,15 +29,13 @@ name='Source/Kata') # pylint: enable=R0801 class RemoveCharTestCase(unittest.TestCase): - """ - Testing remove_char function - """ + """Testing remove_char function.""" def test_remove_char(self): """ - Test that 'remove_char' function - removes the first and - last characters of a string. + Test 'remove_char' function. + + Should remove the first and last characters of a string. :return: """ # pylint: disable=R0801 diff --git a/kyu_8/remove_string_spaces/__init__.py b/kyu_8/remove_string_spaces/__init__.py index e69de29bb2d..9539c9e46bb 100644 --- a/kyu_8/remove_string_spaces/__init__.py +++ b/kyu_8/remove_string_spaces/__init__.py @@ -0,0 +1 @@ +"""Remove String Spaces.""" diff --git a/kyu_8/remove_string_spaces/remove_string_spaces.py b/kyu_8/remove_string_spaces/remove_string_spaces.py index 38d0fcd0605..0711227dd0d 100644 --- a/kyu_8/remove_string_spaces/remove_string_spaces.py +++ b/kyu_8/remove_string_spaces/remove_string_spaces.py @@ -1,5 +1,6 @@ """ -Solution for -> Remove String Spaces +Solution for -> Remove String Spaces. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,8 @@ def no_space(x: str) -> str: """ - Remove the spaces from the string, - then return the resultant string. + Remove the spaces from the string. + :param x: str :return: str """ diff --git a/kyu_8/remove_string_spaces/test_remove_string_spaces.py b/kyu_8/remove_string_spaces/test_remove_string_spaces.py index a2f9bbe5b8b..08a9ab566fc 100644 --- a/kyu_8/remove_string_spaces/test_remove_string_spaces.py +++ b/kyu_8/remove_string_spaces/test_remove_string_spaces.py @@ -1,5 +1,6 @@ """ -Test for -> Remove String Spaces +Test for -> Remove String Spaces. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -28,14 +29,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class NoSpaceTestCase(unittest.TestCase): - """ - Testing no_space function - """ + """Testing no_space function.""" def test_something(self): """ - Test that no_space function removes the spaces - from the string, then return the resultant string. + Test that no_space function with various test dara. + :return: """ # pylint: disable-msg=R0801 diff --git a/kyu_8/reversed_strings/__init__.py b/kyu_8/reversed_strings/__init__.py index e69de29bb2d..0dd0ef57568 100644 --- a/kyu_8/reversed_strings/__init__.py +++ b/kyu_8/reversed_strings/__init__.py @@ -0,0 +1 @@ +"""Reversed Strings.""" diff --git a/kyu_8/reversed_strings/reversed_strings.py b/kyu_8/reversed_strings/reversed_strings.py index ae23a18de99..76c8a9ca868 100644 --- a/kyu_8/reversed_strings/reversed_strings.py +++ b/kyu_8/reversed_strings/reversed_strings.py @@ -1,5 +1,6 @@ """ -Solution for -> Reversed Strings +Solution for -> Reversed Strings. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,8 @@ def solution(string: str) -> str: """ - reverses the string value passed into it + Reverse the string value. + :param string: str :return: str """ diff --git a/kyu_8/reversed_strings/test_reversed_strings.py b/kyu_8/reversed_strings/test_reversed_strings.py index 53188413bf7..14414a52021 100644 --- a/kyu_8/reversed_strings/test_reversed_strings.py +++ b/kyu_8/reversed_strings/test_reversed_strings.py @@ -1,5 +1,6 @@ """ -Test for -> Reversed Strings +Test for -> Reversed Strings. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,13 +27,12 @@ name='Source/Kata') # pylint: enable=R0801 class ReversedStringsTestCase(unittest.TestCase): - """ - Testing the solution for 'Reversed Strings' problem - """ + """Testing the solution for 'Reversed Strings' problem.""" def test_reversed_strings_empty(self): """ - Test with empty string + Test with empty string. + :return: """ # pylint: disable=R0801 @@ -53,7 +53,8 @@ def test_reversed_strings_empty(self): def test_reversed_strings_one_char(self): """ - Test with one char only + Test with one char only. + :return: """ # pylint: disable=R0801 @@ -74,7 +75,8 @@ def test_reversed_strings_one_char(self): def test_reversed_strings(self): """ - Test with regular string + Test with regular string. + :return: """ # pylint: disable=R0801 diff --git a/kyu_8/set_alarm/__init__.py b/kyu_8/set_alarm/__init__.py index e69de29bb2d..0c0881410bf 100644 --- a/kyu_8/set_alarm/__init__.py +++ b/kyu_8/set_alarm/__init__.py @@ -0,0 +1 @@ +"""L1: Set Alarm.""" diff --git a/kyu_8/set_alarm/set_alarm.py b/kyu_8/set_alarm/set_alarm.py index 176c42c2862..45df87cc92e 100644 --- a/kyu_8/set_alarm/set_alarm.py +++ b/kyu_8/set_alarm/set_alarm.py @@ -1,5 +1,6 @@ """ -Test for -> L1: Set Alarm +Test for -> L1: Set Alarm. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,28 +8,19 @@ def set_alarm(employed: bool, vacation: bool) -> bool: """ + 'set_alarm' function. + A function named setAlarm which receives two parameters. The first parameter, employed, is true whenever you are employed and the second parameter, vacation is true whenever you are on vacation. - The function should return true if you are employed and - not on vacation (because these are the circumstances under - which you need to set an alarm). It should return false - otherwise. - Examples: - - setAlarm(true, true) -> false - setAlarm(false, true) -> false - setAlarm(false, false) -> false - setAlarm(true, false) -> true :param employed: bool :param vacation: bool :return: bool """ - if employed and not vacation: return True return False diff --git a/kyu_8/set_alarm/test_set_alarm.py b/kyu_8/set_alarm/test_set_alarm.py index c5767adfa0a..0b0643f102f 100644 --- a/kyu_8/set_alarm/test_set_alarm.py +++ b/kyu_8/set_alarm/test_set_alarm.py @@ -1,5 +1,6 @@ """ -Test for -> L1: Set Alarm +Test for -> L1: Set Alarm. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.set_alarm.set_alarm import set_alarm @@ -26,11 +28,22 @@ name='Source/Kata') # pylint: enable=R0801 class SetAlarmTestCase(unittest.TestCase): - """ - Testing set_alarm function - """ + """Testing set_alarm function.""" - def test_set_alarm(self): + @parameterized.expand([ + ((True, True), + False, + "Fails when input is True, True"), + ((False, True), + False, + "Fails when input is False, True"), + ((False, False), + False, + "Fails when input is False, False"), + ((True, False), + True, + "Fails when input is True, False")]) + def test_set_alarm(self, test_input, expected, msg): """ Testing set_alarm function with various test inputs. @@ -40,7 +53,6 @@ def test_set_alarm(self): false otherwise. Examples: - setAlarm(true, true) -> false setAlarm(false, true) -> false setAlarm(false, false) -> false @@ -55,31 +67,22 @@ def test_set_alarm(self): '' '" + "The function should return true if you are employed and " + "not on vacation (because these are the circumstances under " + "which you need to set an alarm). It should return false " + "otherwise." + '
' + ''
+ 'Examples:'
+ '
'
+ 'setAlarm(true, true) -> false
'
+ 'setAlarm(false, true) -> false
'
+ 'setAlarm(false, false) -> false
'
+ 'setAlarm(true, false) -> true
'
+ "
The player rolls the dice and moves the number" + "of spaces indicated by the dice two times.
" + "Pass position and roll and compare the output" + "to the expected result.
") # pylint: enable=R0801 with allure.step("Test start position zero"): position: int = 0 diff --git a/kyu_8/the_feast_of_many_beasts/__init__.py b/kyu_8/the_feast_of_many_beasts/__init__.py index e69de29bb2d..affe7c98b82 100644 --- a/kyu_8/the_feast_of_many_beasts/__init__.py +++ b/kyu_8/the_feast_of_many_beasts/__init__.py @@ -0,0 +1 @@ +"""The Feast of Many Beasts.""" diff --git a/kyu_8/the_feast_of_many_beasts/feast.py b/kyu_8/the_feast_of_many_beasts/feast.py index d32a6f57b4c..f57febf2c20 100644 --- a/kyu_8/the_feast_of_many_beasts/feast.py +++ b/kyu_8/the_feast_of_many_beasts/feast.py @@ -1,5 +1,6 @@ """ -Solution for -> The Feast of Many Beasts +Solution for -> The Feast of Many Beasts. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,9 @@ def feast(beast: str, dish: str) -> bool: """ - A function feast that takes the animal's name and + 'feast' function. + + A function that takes the animal's name and dish as arguments and returns true or false to indicate whether the beast is allowed to bring the dish to the feast. diff --git a/kyu_8/the_feast_of_many_beasts/test_feast.py b/kyu_8/the_feast_of_many_beasts/test_feast.py index 4e71ede1a98..7e3c9344973 100644 --- a/kyu_8/the_feast_of_many_beasts/test_feast.py +++ b/kyu_8/the_feast_of_many_beasts/test_feast.py @@ -1,5 +1,6 @@ """ -Test for -> The Feast of Many Beasts +Test for -> The Feast of Many Beasts. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,29 +27,12 @@ name='Source/Kata') # pylint: enable=R0801 class FeastTestCase(unittest.TestCase): - """ - Testing 'feast' function - """ + """Testing 'feast' function.""" def test_feast(self): """ - Testing 'feast' function with various test inputs - - Testing a function feast that takes the animal's - name and dish as arguments and returns true or - false to indicate whether the beast is allowed - to bring the dish to the feast. - - Assume that beast and dish are always lowercase strings, - and that each has at least two letters. beast and dish - may contain hyphens and spaces, but these will not appear - at the beginning or end of the string. They will not - contain numerals. + Testing 'feast' function with various test inputs. - There is just one rule: the dish must start and end with - the same letters as the animal's name. For example, the - great blue heron is bringing garlic naan and the chickadee - is bringing chocolate cake. :return: """ # pylint: disable=R0801 @@ -59,7 +43,19 @@ def test_feast(self): '' 'Testing a function feast that takes the animal's " + "name and dish as arguments and returns true or " + "false to indicate whether the beast is allowed " + "to bring the dish to the feast.
" + "Assume that beast and dish are always lowercase strings, " + "and that each has at least two letters. beast and dish " + "may contain hyphens and spaces, but these will not appear " + "at the beginning or end of the string. They will not " + "contain numerals.
" + "There is just one rule: the dish must start and end with " + "the same letters as the animal's name. For example, the " + "great blue heron is bringing garlic naan and the chickadee " + "is bringing chocolate cake.
") # pylint: enable=R0801 with allure.step("Enter animal's name and dish " "as arguments and assert the output"): diff --git a/kyu_8/third_angle_of_triangle/__init__.py b/kyu_8/third_angle_of_triangle/__init__.py index e69de29bb2d..5f11b606f95 100644 --- a/kyu_8/third_angle_of_triangle/__init__.py +++ b/kyu_8/third_angle_of_triangle/__init__.py @@ -0,0 +1 @@ +"""Third Angle of a Triangle.""" diff --git a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py index c1cceafebcc..7066b65393e 100644 --- a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py @@ -1,5 +1,6 @@ """ -Test for -> Third Angle of a Triangle +Test for -> Third Angle of a Triangle. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.third_angle_of_triangle.third_angle_of_triangle \ import other_angle @@ -26,14 +28,17 @@ name='Source/Kata') # pylint: enable-msg=R0801 class OtherAngleTestCase(unittest.TestCase): - """ - Testing other_angle - """ - - def test_other_angle(self): + """Testing other_angle function.""" + + @parameterized.expand([ + (30, 60, 90), + (60, 60, 60), + (43, 78, 59), + (10, 20, 150)]) + def test_other_angle(self, a, b, expected): """ - You are given two angles (in degrees) of a triangle. - Find the 3rd. + Testing other_angle function with various test data. + :return: """ # pylint: disable-msg=R0801 @@ -44,49 +49,9 @@ def test_other_angle(self): '' 'You are given two angles (in degrees) of a triangle." + "Find the 3rd.
") # pylint: enable-msg=R0801 with allure.step("Enter values of two angles and return the 3rd"): - a: int = 30 - b: int = 60 - expected: int = 90 - - print_log(a=a, - b=b, - expected=expected) - - self.assertEqual(other_angle(a, b), expected) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 60 - b = 60 - expected = 60 - - print_log(a=a, - b=b, - expected=expected) - - self.assertEqual(other_angle(a, b), expected) - self.assertEqual(other_angle(60, 60), 60) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 43 - b = 78 - expected = 59 - - print_log(a=a, - b=b, - expected=expected) - - self.assertEqual(other_angle(a, b), expected) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 10 - b = 20 - expected = 150 - - print_log(a=a, - b=b, - expected=expected) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) diff --git a/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py index 4be2862e8a5..560700e45e0 100644 --- a/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py @@ -1,5 +1,6 @@ """ -Solution for -> Third Angle of a Triangle +Solution for -> Third Angle of a Triangle. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def other_angle(a: int, b: int) -> int: """ + Calculate 3rd angle. + You are given two angles (in degrees) of a triangle. Write a function to return the 3rd. Note: only positive integers will be tested. diff --git a/kyu_8/well_of_ideas_easy_version/__init__.py b/kyu_8/well_of_ideas_easy_version/__init__.py index e69de29bb2d..c4a87c311a7 100644 --- a/kyu_8/well_of_ideas_easy_version/__init__.py +++ b/kyu_8/well_of_ideas_easy_version/__init__.py @@ -0,0 +1 @@ +"""Well of Ideas - Easy Version.""" diff --git a/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py b/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py index 98a48f7b720..a176416565b 100644 --- a/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py +++ b/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py @@ -1,5 +1,6 @@ """ -Tests for -> Well of Ideas - Easy Version +Tests for -> Well of Ideas - Easy Version. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,14 +30,12 @@ name='Source/Kata') # pylint: enable=R0801 class WellTestCase(unittest.TestCase): - """ - Testing well function - """ + """Testing 'well' function.""" def test_well_fail(self): """ - If there are no good ideas, - as is often the case, return 'Fail!'. + If there are no good ideas, as is often the case, return 'Fail!'. + :return: """ # pylint: disable=R0801 @@ -44,10 +43,11 @@ def test_well_fail(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'If there are no good ideas, return 'Fail!'.
") # pylint: enable=R0801 with allure.step("Pass list with no 'good' in it"): lst: list = ['bad', 'bad', 'bad'] @@ -57,8 +57,8 @@ def test_well_fail(self): def test_well_publish(self): """ - If there are one or two good ideas, - return 'Publish!', + If there are one or two good ideas, return 'Publish!'. + :return: """ # pylint: disable=R0801 @@ -69,7 +69,7 @@ def test_well_publish(self): '' 'If there are one or two good ideas, return 'Publish!'
") # pylint: enable=R0801 with allure.step("Pass list with one 'good' in it"): lst: list = ['good', 'bad', 'bad', 'bad', 'bad'] @@ -79,8 +79,8 @@ def test_well_publish(self): def test_well_series(self): """ - if there are more than 2 return - 'I smell a series!'. + If there are more than 2 return 'I smell a series!'. + :return: """ # pylint: disable=R0801 @@ -91,7 +91,7 @@ def test_well_series(self): '' 'If there are more than 2 return 'I smell a series!'
") # pylint: enable=R0801 with allure.step("Pass list with more than 2 'good' in it"): lst: list = ['good', 'bad', 'bad', diff --git a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py index 1537dd77892..637a8e19afb 100644 --- a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py +++ b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py @@ -1,5 +1,6 @@ """ -Solution for -> Well of Ideas - Easy Version +Solution for -> Well of Ideas - Easy Version. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,9 +10,8 @@ def well(x: List[str]) -> str: """ - If there are one or two good ideas, return 'Publish!'. - If there are more than 2 return 'I smell a series!'. - If there are no good ideas, return 'Fail!'. + 'well' function. + :param x: List[str] :return: str """ diff --git a/kyu_8/will_there_be_enough_space/__init__.py b/kyu_8/will_there_be_enough_space/__init__.py index e69de29bb2d..dfef7dcb40f 100644 --- a/kyu_8/will_there_be_enough_space/__init__.py +++ b/kyu_8/will_there_be_enough_space/__init__.py @@ -0,0 +1 @@ +"""Will there be enough space.""" diff --git a/kyu_8/will_there_be_enough_space/enough.py b/kyu_8/will_there_be_enough_space/enough.py index aac42941813..c320e23d1e7 100644 --- a/kyu_8/will_there_be_enough_space/enough.py +++ b/kyu_8/will_there_be_enough_space/enough.py @@ -1,5 +1,6 @@ """ -Solution for -> Will there be enough space? +Solution for -> Will there be enough space?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def enough(cap: int, on: int, wait: int) -> int: """ + 'enough' function. + The driver wants you to write a simple program telling him if he will be able to fit all the passengers. @@ -18,7 +21,6 @@ def enough(cap: int, on: int, wait: int) -> int: cap is the amount of people the bus can hold excluding the driver. on is the number of people on the bus. wait is the number of people waiting to get on to the bus. - :param cap: int :param on: int :param wait: int diff --git a/kyu_8/will_there_be_enough_space/test_enough.py b/kyu_8/will_there_be_enough_space/test_enough.py index cb537d703fd..fe941f70f34 100644 --- a/kyu_8/will_there_be_enough_space/test_enough.py +++ b/kyu_8/will_there_be_enough_space/test_enough.py @@ -1,5 +1,6 @@ """ -Tests for -> Will there be enough space? +Tests for -> Will there be enough space?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.will_there_be_enough_space.enough import enough @@ -26,46 +28,37 @@ name='Source/Kata') # pylint: enable=R0801 class EnoughTestCase(unittest.TestCase): - """ - Testing enough function - """ + """Testing enough function.""" - def test_enough(self): + @parameterized.expand([ + ((10, 5, 5), 0), + ((100, 60, 50), 10), + ((20, 5, 5), 0)]) + def test_enough(self, test_dat, expected): """ - Testing enough function - with various test data + Testing enough function with various test data. - If there is enough space, return 0, - and if there isn't, return the number - of passengers he can't take. :return: """ # pylint: disable=R0801 - allure.dynamic.title("STesting enough function") + allure.dynamic.title("Testing enough function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'If there is enough space, return 0, " + "and if there isn't, return the number " + "of passengers he can't take.
") # pylint: enable=R0801 - with allure.step("Enter test data and " - "verify the output"): - test_data: tuple = ( - ((10, 5, 5), 0), - ((100, 60, 50), 10), - ((20, 5, 5), 0)) - - for test_dat, expected in test_data: - cap: int = test_dat[0] - on: int = test_dat[1] - wait: int = test_dat[2] - - print_log(cap=cap, - on=on, - wait=wait, - expected=expected) - - self.assertEqual(expected, - enough(cap, on, wait)) + with allure.step(f"Enter test data: {test_dat} " + f"and verify the expected output: {expected}."): + cap: int = test_dat[0] + on: int = test_dat[1] + wait: int = test_dat[2] + print_log(cap=cap, + on=on, + wait=wait, + expected=expected) + self.assertEqual(expected, enough(cap, on, wait)) diff --git a/kyu_8/will_you_make_it/README.md b/kyu_8/will_you_make_it/README.md index 609ab919f9f..1daf2e24c9d 100644 --- a/kyu_8/will_you_make_it/README.md +++ b/kyu_8/will_you_make_it/README.md @@ -1,4 +1,4 @@ -# Will you make it +# Will you make it? You were camping with your friends far away from home, but when it's time to go back, you realize that you fuel is running out diff --git a/kyu_8/will_you_make_it/__init__.py b/kyu_8/will_you_make_it/__init__.py index e69de29bb2d..8c9870dbbff 100644 --- a/kyu_8/will_you_make_it/__init__.py +++ b/kyu_8/will_you_make_it/__init__.py @@ -0,0 +1 @@ +"""Will you make it?.""" diff --git a/kyu_8/will_you_make_it/test_zero_fuel.py b/kyu_8/will_you_make_it/test_zero_fuel.py index 6ef2863739f..25be63c50e0 100644 --- a/kyu_8/will_you_make_it/test_zero_fuel.py +++ b/kyu_8/will_you_make_it/test_zero_fuel.py @@ -1,5 +1,6 @@ """ -Tests for -> Will you make it? +Tests for -> Will you make it?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from kyu_8.will_you_make_it.zero_fuel import zero_fuel from utils.log_func import print_log @@ -28,13 +30,15 @@ name='Source/Kata') # pylint: enable=R0801 class ZeroFuelTestCase(unittest.TestCase): - """ - Testing zero_fuel - """ + """Testing zero_fuel function.""" - def test_zero_fuel(self): + @parameterized.expand([ + ((50, 25, 2), True), + ((100, 50, 1), False)]) + def test_zero_fuel(self, data, expected): """ - Testing the function with various test data + Testing the function with various test data. + :return: """ # pylint: disable=R0801 @@ -42,8 +46,9 @@ def test_zero_fuel(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'You were camping with your friends far away from home, " "but when it's time to go back, you realize that you fuel " @@ -51,23 +56,13 @@ def test_zero_fuel(self): "know that on average, your car runs on about 25 miles per " "gallon. There are 2 gallons left. Considering these factors, " "write a function that tells you if it is possible to get to " - "the pump or not. Function should return true (1 in Prolog) if " - "it is possible and false (0 in Prolog) if not. The input values " - "are always positive.
") + "the pump or not. Function should return true (1 in Prolog) " + "if it is possible and false (0 in Prolog) if not. The input " + "values are always positive.") # pylint: enable=R0801 - test_data: tuple = ( - ((50, 25, 2), True), - ((100, 50, 1), False)) - - for data, expected in test_data: - actual_result = zero_fuel(data[0], data[1], data[2]) - with allure.step(f"Enter data ({data}) and verify the " - f"expected output ({expected}) " - f"vs actual result ({actual_result})"): - - print_log(data=data, - expected=expected, - result=actual_result) - - self.assertEqual(expected, - actual_result) + actual_result = zero_fuel(data[0], data[1], data[2]) + with allure.step(f"Enter data ({data}) and verify the " + f"expected output ({expected}) " + f"vs actual result ({actual_result})"): + print_log(data=data, expected=expected, result=actual_result) + self.assertEqual(expected, actual_result) diff --git a/kyu_8/will_you_make_it/zero_fuel.py b/kyu_8/will_you_make_it/zero_fuel.py index dfdc00d6572..0e97db3fb85 100644 --- a/kyu_8/will_you_make_it/zero_fuel.py +++ b/kyu_8/will_you_make_it/zero_fuel.py @@ -1,12 +1,17 @@ """ -Solution for -> Will you make it? +Solution for -> Will you make it?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ -def zero_fuel(distance_to_pump: int, mpg: int, fuel_left: int) -> bool: +def zero_fuel(distance_to_pump: int, + mpg: int, + fuel_left: int) -> bool: """ + 'zero_fuel' function. + You were camping with your friends far away from home, but when it's time to go back, you realize that you fuel is running out and the nearest pump is 50 miles away! @@ -16,7 +21,6 @@ def zero_fuel(distance_to_pump: int, mpg: int, fuel_left: int) -> bool: to get to the pump or not. Function should return true (1 in Prolog) if it is possible and false (0 in Prolog) if not. The input values are always positive. - :param distance_to_pump: int :param mpg: int :param fuel_left: int diff --git a/kyu_8/wolf_in_sheep_clothing/__init__.py b/kyu_8/wolf_in_sheep_clothing/__init__.py index e69de29bb2d..6833659fbbf 100644 --- a/kyu_8/wolf_in_sheep_clothing/__init__.py +++ b/kyu_8/wolf_in_sheep_clothing/__init__.py @@ -0,0 +1 @@ +"""A wolf in sheep's clothing.""" diff --git a/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py b/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py index 5fd1ee09df0..b7f440e2cea 100644 --- a/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py +++ b/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py @@ -1,5 +1,6 @@ """ -Tests for -> A wolf in sheep's clothing +Tests for -> A wolf in sheep's clothing. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,16 +25,17 @@ 'ARRAYS', 'LOOPS', 'CONTROL FLOW') -@allure.link(url='https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15', + name='Source/Kata') # pylint: enable=R0801 class WarnTheSheepTestCase(unittest.TestCase): - """ - Testing warn_the_sheep function - """ + """Testing warn_the_sheep function.""" def test_warn_the_sheep_wolf_at_start(self): """ + Test the 'warn' func when the wolf in the beginning. + If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". :return: @@ -46,7 +48,8 @@ def test_warn_the_sheep_wolf_at_start(self): '' 'If the wolf is the closest animal to you, " + "return \"Pls go away and stop eating my sheep\".
") # pylint: enable=R0801 lst: list = ['wolf', 'sheep', 'sheep', 'sheep', 'sheep', 'sheep', @@ -60,6 +63,8 @@ def test_warn_the_sheep_wolf_at_start(self): def test_warn_the_sheep_wolf_in_middle(self): """ + Test the 'warn' func when the wolf in the middle. + If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". :return: @@ -72,7 +77,8 @@ def test_warn_the_sheep_wolf_in_middle(self): '' 'If the wolf is the closest animal to you, " + "return \"Pls go away and stop eating my sheep\".
") # pylint: enable=R0801 # 1 lst: list = ['sheep', 'sheep', 'sheep', @@ -107,6 +113,8 @@ def test_warn_the_sheep_wolf_in_middle(self): def test_warn_the_sheep_wolf_at_end(self): """ + Test the 'warn' func when the wolf in the end. + If the wolf is not the closest animal to you, return "Oi! Sheep number N! You are about to be eaten by a wolf!" where N is the sheep's position in the queue. @@ -120,7 +128,9 @@ def test_warn_the_sheep_wolf_at_end(self): '' 'If the wolf is not the closest animal to you, " + "return \"Oi! Sheep number N! You are about to be eaten by a wolf!\" " + "where N is the sheep's position in the queue.
") # pylint: enable=R0801 lst: list = ['sheep', 'sheep', 'wolf'] expected: str = 'Pls go away and stop eating my sheep' diff --git a/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py b/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py index 7057389988e..628457e199f 100644 --- a/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py +++ b/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py @@ -1,5 +1,6 @@ """ -Solution for -> A wolf in sheep's clothing +Solution for -> A wolf in sheep's clothing. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,7 @@ def warn_the_sheep(queue: list) -> str: """ - Warn the sheep in front of the wolf - that it is about to be eaten. + Warn the sheep in front of the wolf. If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep".