From 94ac9d5abee7be6fb6cfeb330a1b802f28aac048 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 13:46:31 -0800 Subject: [PATCH 01/81] Update README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cdec1fb788d..1e7faaefbfa 100644 --- a/README.md +++ b/README.md @@ -354,13 +354,11 @@ the environment for every build, see comment from Grimmy below).
ERROR: The term 'make' is not recognized as the name of a cmdlet -'make' is not recognized as an internal or external command. - The error "'make' is not recognized as an internal or external command, operable program or batch file" occurs when we run the make command on Windows without having make installed. To solve the error, install make using Chocolatey. -``` +```bash make clean make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. @@ -378,18 +376,18 @@ To install Chocolatey: 1. Open PowerShell as an administrator. 2. Run the following command: - ``` + ```bash Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) ``` 3. Wait for the command to complete. 4. Type choco to make sure Chocolatey is installed: - ``` + ```bash PS C:\WINDOWS\system32> choco Chocolatey v2.4.1 Please run 'choco -?' or 'choco -?' for help menu. ``` 5. Now that you have Chocolatey installed, run the following command to install make: - ``` + ```bash PS C:\WINDOWS\system32> choco install make -y Chocolatey v2.4.1 Installing the following packages: From 7fa7c05b4fdf35d2dbc04d3c84196f006323b833 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:03:40 -0800 Subject: [PATCH 02/81] Create pydocstyle_kyu8.yml --- .github/workflows/pydocstyle_kyu8.yml | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/pydocstyle_kyu8.yml 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 From b58a30c8631fbdb78d9738378d0d8abdfe643de7 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:06:42 -0800 Subject: [PATCH 03/81] Update __init__.py --- kyu_8/__init__.py | 1 + 1 file changed, 1 insertion(+) 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.""" From 4e7cae11fa9d7eacc68c8ab7d87aa930e32e64f0 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:14:21 -0800 Subject: [PATCH 04/81] ALTerNAtiNG CaSe --- kyu_8/alternating_case/__init__.py | 1 + kyu_8/alternating_case/alternating_case.py | 11 ++-- .../alternating_case/test_alternating_case.py | 51 +++++++++---------- 3 files changed, 33 insertions(+), 30 deletions(-) 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..44c51a05212 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: """ + Alternating case. + each lowercase letter becomes uppercase and - each uppercase letter becomes lowercase - :param string: - :return: + 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( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 - with allure.step("Enter test string and verify the output"): - test_data: tuple = ( - ("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")) - - for d in test_data: - string = d[0] - expected = d[1] - print_log(string=string, expected=expected) - self.assertEqual(to_alternating_case(string), expected) + with allure.step(f"Enter test string: {string} " + f"and verify the expected output: {expected}."): + print_log(string=string, expected=expected) + self.assertEqual(to_alternating_case(string), expected) From 8f119481e12168ff46a59eb59580aab471ab24d1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:16:04 -0800 Subject: [PATCH 05/81] Update alternating_case.py --- kyu_8/alternating_case/alternating_case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/alternating_case/alternating_case.py b/kyu_8/alternating_case/alternating_case.py index 44c51a05212..f298b2e7c23 100644 --- a/kyu_8/alternating_case/alternating_case.py +++ b/kyu_8/alternating_case/alternating_case.py @@ -10,7 +10,7 @@ def to_alternating_case(string: str) -> str: """ Alternating case. - each lowercase letter becomes uppercase and + Each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. :param string: str :return: str From 99ac469e08b75e2e1e2b6ee116be6f1f6e82000a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:25:04 -0800 Subject: [PATCH 06/81] # Century From Year --- kyu_8/century_from_year/__init__.py | 1 + kyu_8/century_from_year/century.py | 6 ++- kyu_8/century_from_year/test_century.py | 58 +++++++++++++------------ 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/kyu_8/century_from_year/__init__.py b/kyu_8/century_from_year/__init__.py index e69de29bb2d..228c0682982 100644 --- a/kyu_8/century_from_year/__init__.py +++ b/kyu_8/century_from_year/__init__.py @@ -0,0 +1 @@ +"""Century From Year.""" diff --git a/kyu_8/century_from_year/century.py b/kyu_8/century_from_year/century.py index b3687eb368f..b6406ec4aa0 100644 --- a/kyu_8/century_from_year/century.py +++ b/kyu_8/century_from_year/century.py @@ -1,5 +1,6 @@ """ -Solution for -> Century From Year +Solution for -> Century From Year. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,8 @@ def century(year: int) -> int: """ - Given a year, return the century it is in + Given a year, return the century it is in. + :param year: int :return: int """ diff --git a/kyu_8/century_from_year/test_century.py b/kyu_8/century_from_year/test_century.py index 1c86b9c549c..37cf962a18b 100644 --- a/kyu_8/century_from_year/test_century.py +++ b/kyu_8/century_from_year/test_century.py @@ -1,5 +1,6 @@ """ -Test for -> Century From Year +Test for -> Century From Year. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,6 +10,7 @@ import unittest import allure +from parameterized import parameterized from kyu_8.century_from_year.century import century from utils.log_func import print_log @@ -32,45 +34,45 @@ # pylint: enable-msg=R0801 class CenturyTestCase(unittest.TestCase): """ + Testing century function. + The first century spans from the year 1 up to and including the year 100, The second - from the year 101 up to and including the year 200, etc. """ - def test_century(self): + @parameterized.expand([ + (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')]) + def test_century(self, year, expected, message): """ - Testing century function + Testing century function with various test data. + + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing century function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

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) From a7119bf09a2a8765cd95cac310d6d866bd6ca244 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:31:13 -0800 Subject: [PATCH 07/81] # Check the exam --- kyu_8/check_the_exam/__init__.py | 1 + kyu_8/check_the_exam/check_exam.py | 8 +++-- kyu_8/check_the_exam/test_check_exam.py | 47 +++++++++++-------------- 3 files changed, 27 insertions(+), 29 deletions(-) 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..2651f359112 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 + Processing 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( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 with allure.step("Enter arr1 and arr2 and verify the output"): - data: tuple = ( - (["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)) - - for arr1, arr2, expected in data: - print_log(arr1=arr1, - arr2=arr2, - expected=expected) - - self.assertEqual(expected, - check_exam(arr1, arr2)) + print_log(arr1=arr1, arr2=arr2, expected=expected) + self.assertEqual(expected, check_exam(arr1, arr2)) From 9a68f048faf41cf50ed5f7b014eff736a8b04e75 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:15:55 -0800 Subject: [PATCH 08/81] # Convert a string to an array --- kyu_8/convert_string_to_an_array/__init__.py | 1 + .../string_to_array.py | 7 ++-- .../test_string_to_array.py | 33 +++++++++---------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/kyu_8/convert_string_to_an_array/__init__.py b/kyu_8/convert_string_to_an_array/__init__.py index e69de29bb2d..a236a70d07e 100644 --- a/kyu_8/convert_string_to_an_array/__init__.py +++ b/kyu_8/convert_string_to_an_array/__init__.py @@ -0,0 +1 @@ +"""Convert a string to an array.""" diff --git a/kyu_8/convert_string_to_an_array/string_to_array.py b/kyu_8/convert_string_to_an_array/string_to_array.py index 724f48905f5..14fa4a648a0 100644 --- a/kyu_8/convert_string_to_an_array/string_to_array.py +++ b/kyu_8/convert_string_to_an_array/string_to_array.py @@ -1,5 +1,6 @@ """ -Solution for -> Convert a string to an array +Solution for -> Convert a string to an array. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,8 @@ def string_to_array(s: str) -> list: """ - A function to split a string and - convert it into an array of words + Split a string and convert it into an array of words. + :param s: str :return: list """ diff --git a/kyu_8/convert_string_to_an_array/test_string_to_array.py b/kyu_8/convert_string_to_an_array/test_string_to_array.py index d389160b0cd..72f48dfe51e 100644 --- a/kyu_8/convert_string_to_an_array/test_string_to_array.py +++ b/kyu_8/convert_string_to_an_array/test_string_to_array.py @@ -1,5 +1,6 @@ """ -Test for -> Convert a string to an array +Test for -> Convert a string to an array. + 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.convert_string_to_an_array.string_to_array \ import string_to_array @@ -28,11 +30,16 @@ name='Source/Kata') # pylint: enable=R0801 class StringToArrayTestCase(unittest.TestCase): - """ - Testing string_to_array function. - """ + """Testing string_to_array function.""" - def test_string_to_array(self): + @parameterized.expand([ + ("Robin Singh", ["Robin", "Singh"]), + ("CodeWars", ["CodeWars"]), + ("I love arrays they are my favorite", + ["I", "love", "arrays", "they", "are", "my", "favorite"]), + ("1 2 3", ["1", "2", "3"]), + ("", [""])]) + def test_string_to_array(self, s, expected): """ Testing string_to_array function. @@ -50,15 +57,7 @@ def test_string_to_array(self): '

Test Description:

' "

") # pylint: enable=R0801 - with allure.step("Enter a test string and verify the output"): - test_data: tuple = ( - ("Robin Singh", ["Robin", "Singh"]), - ("CodeWars", ["CodeWars"]), - ("I love arrays they are my favorite", - ["I", "love", "arrays", "they", "are", "my", "favorite"]), - ("1 2 3", ["1", "2", "3"]), - ("", [""])) - - for s, expected in test_data: - print_log(s=s, expected=expected) - self.assertEqual(expected, string_to_array(s)) + with allure.step(f"Enter a test string: {s} " + f"and verify the output: {expected}."): + print_log(s=s, expected=expected) + self.assertEqual(expected, string_to_array(s)) From e2654a6522fd7a2dc556f3e773bd26bbe99508fe Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:22:14 -0800 Subject: [PATCH 09/81] Count the Monkeys!. --- kyu_8/count_the_monkeys/__init__.py | 1 + kyu_8/count_the_monkeys/monkey_count.py | 5 ++- kyu_8/count_the_monkeys/test_monkey_count.py | 37 ++++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/kyu_8/count_the_monkeys/__init__.py b/kyu_8/count_the_monkeys/__init__.py index e69de29bb2d..3eca16bf08d 100644 --- a/kyu_8/count_the_monkeys/__init__.py +++ b/kyu_8/count_the_monkeys/__init__.py @@ -0,0 +1 @@ +"""Count the Monkeys.""" diff --git a/kyu_8/count_the_monkeys/monkey_count.py b/kyu_8/count_the_monkeys/monkey_count.py index c089aa86894..bf4467b021a 100644 --- a/kyu_8/count_the_monkeys/monkey_count.py +++ b/kyu_8/count_the_monkeys/monkey_count.py @@ -1,5 +1,6 @@ """ -Solution for -> Count the Monkeys! +Solution for -> Count the Monkeys!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def monkey_count(n: int) -> list: """ + Count monkeys. + You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full diff --git a/kyu_8/count_the_monkeys/test_monkey_count.py b/kyu_8/count_the_monkeys/test_monkey_count.py index 095047df308..24e7e002a84 100644 --- a/kyu_8/count_the_monkeys/test_monkey_count.py +++ b/kyu_8/count_the_monkeys/test_monkey_count.py @@ -1,5 +1,6 @@ """ -Test for -> Count the Monkeys! +Test for -> Count the Monkeys!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,6 +10,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.count_the_monkeys.monkey_count \ import monkey_count @@ -33,13 +35,19 @@ name='Source/Kata') # pylint: enable=R0801 class MonkeyCountTestCase(unittest.TestCase): - """ - Testing monkey_count function - """ + """Testing monkey_count function.""" - def test_monkey_count(self): + @parameterized.expand([ + (1, [1]), + (5, [1, 2, 3, 4, 5]), + (3, [1, 2, 3]), + (9, [1, 2, 3, 4, 5, 6, 7, 8, 9]), + (10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + (20, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20])]) + def test_monkey_count(self, n, expected): """ - Testing monkey_count function + Testing monkey_count function. You take your son to the forest to see the monkeys. You know that there are a certain number there (n), @@ -62,16 +70,7 @@ def test_monkey_count(self): '

Test Description:

' "

") # pylint: enable=R0801 - with allure.step("Enter a number (int) and verify the output"): - test_data: tuple = ( - (1, [1]), - (5, [1, 2, 3, 4, 5]), - (3, [1, 2, 3]), - (9, [1, 2, 3, 4, 5, 6, 7, 8, 9]), - (10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), - (20, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20])) - - for n, expected in test_data: - print_log(n=n, expected=expected) - self.assertEqual(expected, monkey_count(n)) + with allure.step(f"Enter a number (int): {n} " + f"and verify the expected output: {expected}."): + print_log(n=n, expected=expected) + self.assertEqual(expected, monkey_count(n)) From 3ffa4e19888c40dea4b5284c66d4bee31aa5d08e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:29:19 -0800 Subject: [PATCH 10/81] Counting sheep --- kyu_8/counting_sheep/__init__.py | 1 + kyu_8/counting_sheep/counting_sheep.py | 13 +++-- kyu_8/counting_sheep/test_counting_sheep.py | 56 ++++++++++++--------- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/kyu_8/counting_sheep/__init__.py b/kyu_8/counting_sheep/__init__.py index e69de29bb2d..b676058b62c 100644 --- a/kyu_8/counting_sheep/__init__.py +++ b/kyu_8/counting_sheep/__init__.py @@ -0,0 +1 @@ +"""Counting sheep.""" diff --git a/kyu_8/counting_sheep/counting_sheep.py b/kyu_8/counting_sheep/counting_sheep.py index be4c8583b89..8ade6f78b92 100644 --- a/kyu_8/counting_sheep/counting_sheep.py +++ b/kyu_8/counting_sheep/counting_sheep.py @@ -1,12 +1,15 @@ """ Solution for -> Counting sheep... + Created by Egor Kostan. GitHub: https://github.com/ikostan """ -def count_sheeps(array_of_sheeps: list) -> int: +def count_sheep(array_of_sheep: list) -> int: """ + Count sheep. + Consider an array of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep @@ -14,8 +17,8 @@ def count_sheeps(array_of_sheeps: list) -> int: Hint: Don't forget to check for bad values like null/undefined - :param array_of_sheeps: - :return: + :param array_of_sheep: list + :return: int """ - return 0 if array_of_sheeps is None \ - else array_of_sheeps.count(True) + return 0 if array_of_sheep is None \ + else array_of_sheep.count(True) diff --git a/kyu_8/counting_sheep/test_counting_sheep.py b/kyu_8/counting_sheep/test_counting_sheep.py index 5b48b889a49..0f1c9eb47bd 100644 --- a/kyu_8/counting_sheep/test_counting_sheep.py +++ b/kyu_8/counting_sheep/test_counting_sheep.py @@ -1,5 +1,6 @@ """ Test for -> Counting sheep... + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,7 +10,7 @@ import unittest import allure from utils.log_func import print_log -from kyu_8.counting_sheep.counting_sheep import count_sheeps +from kyu_8.counting_sheep.counting_sheep import count_sheep # pylint: disable=R0801 @@ -26,13 +27,12 @@ name='Source/Kata') # pylint: enable=R0801 class CountingSheepTestCase(unittest.TestCase): - """ - Testing 'count_sheeps' function - """ + """Testing 'count_sheep' function.""" def test_counting_sheep(self): """ - Testing 'count_sheeps' function + Testing 'count_sheep' function. + Consider an array of sheep where some sheep may be missing from their place. We need a function that counts the @@ -42,12 +42,13 @@ def test_counting_sheep(self): """ # pylint: disable=R0801 allure.dynamic.title( - "Testing 'count_sheeps' function: positive flow") + "Testing 'count_sheep' function: positive flow") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 @@ -60,13 +61,14 @@ def test_counting_sheep(self): expected: int = 17 print_log(list=lst, expected=expected) self.assertEqual(expected, - count_sheeps(lst), + count_sheep(lst), f"There are 17 sheep in total, " - f"not {count_sheeps(lst)}") + f"not {count_sheep(lst)}") def test_counting_sheep_bad_input(self): """ - Testing 'count_sheeps' function + Testing 'count_sheep' function, invalid values. + Hint: Don't forget to check for bad values like null/undefined :return: @@ -86,25 +88,27 @@ def test_counting_sheep_bad_input(self): expected: int = 0 print_log(list=lst, expected=expected) self.assertEqual(expected, - count_sheeps(lst), + count_sheep(lst), f"There are 0 sheep in total, " - f"not {count_sheeps(lst)}") + f"not {count_sheep(lst)}") def test_counting_sheep_empty_list(self): """ - Testing 'count_sheeps' function + Testing 'count_sheep' function, empty list. + Hint: Don't forget to check for bad values like empty list :return: """ # pylint: disable=R0801 allure.dynamic.title( - "Testing 'count_sheeps' function: empty list") + "Testing 'count_sheep' function: empty list") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 @@ -112,25 +116,27 @@ def test_counting_sheep_empty_list(self): expected: int = 0 print_log(list=lst, expected=expected) self.assertEqual(expected, - count_sheeps(lst), + count_sheep(lst), f"There are 0 sheep in total, " - f"not {count_sheeps(lst)}") + f"not {count_sheep(lst)}") def test_counting_sheep_mixed_list(self): """ - Testing 'count_sheeps' function + Testing 'count_sheep' function, null value. + Hint: Don't forget to check for bad values like mixed list :return: """ # pylint: disable=R0801 allure.dynamic.title( - "Testing 'count_sheeps' function: mixed list") + "Testing 'count_sheep' function: mixed list") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 @@ -138,6 +144,6 @@ def test_counting_sheep_mixed_list(self): expected: int = 1 print_log(list=lst, expected=expected) self.assertEqual(expected, - count_sheeps(lst), + count_sheep(lst), f"There are 0 sheep in total, " - f"not {count_sheeps(lst)}") + f"not {count_sheep(lst)}") From 2905ff43b8a23d848c11044efc3b400ad38abee6 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:34:18 -0800 Subject: [PATCH 11/81] Enumerable Magic #25 - Take the First N Elements. --- kyu_8/enumerable_magic_25/__init__.py | 1 + kyu_8/enumerable_magic_25/take.py | 7 +++- kyu_8/enumerable_magic_25/test_take.py | 52 +++++++++++--------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/kyu_8/enumerable_magic_25/__init__.py b/kyu_8/enumerable_magic_25/__init__.py index e69de29bb2d..410c8d0558c 100644 --- a/kyu_8/enumerable_magic_25/__init__.py +++ b/kyu_8/enumerable_magic_25/__init__.py @@ -0,0 +1 @@ +"""Enumerable Magic #25 - Take the First N Elements.""" diff --git a/kyu_8/enumerable_magic_25/take.py b/kyu_8/enumerable_magic_25/take.py index 107e0bb3450..0512f533432 100644 --- a/kyu_8/enumerable_magic_25/take.py +++ b/kyu_8/enumerable_magic_25/take.py @@ -1,5 +1,6 @@ """ -Solution for -> Enumerable Magic #25 - Take the First N Elements +Solution for -> Enumerable Magic #25 - Take the First N Elements. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,10 @@ def take(arr: list, n: int) -> list: """ + 'take' function. + Accepts a list/array and a number n, - and returns a list/array array of the + and returns a list/array of the first n elements from the list/array. :param arr: list diff --git a/kyu_8/enumerable_magic_25/test_take.py b/kyu_8/enumerable_magic_25/test_take.py index ab1cb2d98ba..97d7be1a043 100644 --- a/kyu_8/enumerable_magic_25/test_take.py +++ b/kyu_8/enumerable_magic_25/test_take.py @@ -1,5 +1,6 @@ """ -Test for -> Enumerable Magic #25 - Take the First N Elements +Test for -> Enumerable Magic #25 - Take the First N Elements. + 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.enumerable_magic_25.take import take @@ -25,13 +27,17 @@ name='Source/Kata') # pylint: enable=R0801 class TakeTestCase(unittest.TestCase): - """ - Testing take function - """ + """Testing 'take' function.""" - def test_take(self): + @parameterized.expand([ + ([0, 1, 2, 3, 5, 8, 13], 3, [0, 1, 2]), + ([51], 35, [51]), + ([], 3, []), + ([0, 1, 2, 3, 5, 8, 13], 0, [])]) + def test_take(self, arr, n, expected): """ - Testing the function with various test data + Testing the function with various test data. + :return: """ # pylint: disable=R0801 @@ -39,8 +45,9 @@ def test_take(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

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) From 625967ad9bdb6b67df91cd58bc283d471cd890cc Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:48:30 -0800 Subject: [PATCH 12/81] # Find the first non-consecutive number --- .../__init__.py | 1 + .../first_non_consecutive.py | 3 +- .../test_first_non_consecutive.py | 42 ++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) 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..5d551d5ef4e 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.""" \ No newline at end of file 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( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 - with allure.step("Pass a list with no non consecutive numbers"): + with allure.step("Pass a list with non-consecutive numbers"): lst: list = [1, 2, 3, 4, 5, 6, 7, 8] expected: None = None @@ -62,7 +64,8 @@ def test_first_non_consecutive_none(self): def test_first_non_consecutive_large_list(self): """ - Large lists + Testing large lists. + :return: """ # pylint: disable=R0801 @@ -70,8 +73,9 @@ def test_first_non_consecutive_large_list(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 @@ -114,6 +118,8 @@ def test_first_non_consecutive_large_list(self): def test_first_non_consecutive_positive(self): """ + Test non-consecutive positive numbers. + If we have an array [1,2,3,4,6,7,8] then 1 then 2 then 3 then 4 are all consecutive but 6 is not, so that's the first non-consecutive number. @@ -124,8 +130,9 @@ def test_first_non_consecutive_positive(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 @@ -170,16 +177,19 @@ def test_first_non_consecutive_positive(self): def test_first_non_consecutive_negative(self): """ - non-consecutive is a negative number. + Test non-consecutive is a negative number. + :return: """ # pylint: disable=R0801 - allure.dynamic.title("Negative non consecutive number should be returned") + allure.dynamic.title( + "Negative non consecutive number should be returned") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 From 7e6d0be998929659dbd5cdb2ac5deae6381babd3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 02:57:05 -0800 Subject: [PATCH 13/81] Formatting decimal places #0 --- kyu_8/formatting_decimal_places_0/__init__.py | 1 + .../test_two_decimal_places.py | 46 +++++++++---------- .../two_decimal_places.py | 5 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/kyu_8/formatting_decimal_places_0/__init__.py b/kyu_8/formatting_decimal_places_0/__init__.py index e69de29bb2d..1ced7a92204 100644 --- a/kyu_8/formatting_decimal_places_0/__init__.py +++ b/kyu_8/formatting_decimal_places_0/__init__.py @@ -0,0 +1 @@ +"""Formatting decimal places #0.""" diff --git a/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py b/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py index d25a74b52da..057315550ba 100644 --- a/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py +++ b/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py @@ -1,5 +1,6 @@ """ -Test for -> Formatting decimal places #0 +Test for -> Formatting decimal places #0. + 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.formatting_decimal_places_0.two_decimal_places \ import two_decimal_places @@ -29,14 +31,21 @@ name='Source/Kata') # pylint: enable=R0801 class TwoDecimalPlacesTestCase(unittest.TestCase): - """ - Testing two_decimal_places function - """ + """Testing two_decimal_places function.""" - def test_two_decimal_places(self): + @parameterized.expand([ + (4.659725356, + 4.66, + "didn't work for 4.659725356"), + (173735326.3783732637948948, + 173735326.38, + "didn't work for 173735326.3783732637948948"), + (4.653725356, + 4.65, + "didn't work for 4.653725356")]) + def test_two_decimal_places(self, n, expected, msg): """ - Testing two_decimal_places function - with various test inputs. + Testing two_decimal_places function with various test inputs. Each number should be formatted that it is rounded to two decimal places. You don't @@ -50,25 +59,12 @@ def test_two_decimal_places(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 with allure.step("Pass a number and verify the output"): - data: tuple = ( - (4.659725356, - 4.66, - "didn't work for 4.659725356"), - (173735326.3783732637948948, - 173735326.38, - "didn't work for 173735326.3783732637948948"), - (4.653725356, - 4.65, - "didn't work for 4.653725356")) - - for n, expected, msg in data: - print_log(n=n, expected=expected) - self.assertEqual(expected, - two_decimal_places(n), - msg) + print_log(n=n, expected=expected) + self.assertEqual(expected, two_decimal_places(n), msg) diff --git a/kyu_8/formatting_decimal_places_0/two_decimal_places.py b/kyu_8/formatting_decimal_places_0/two_decimal_places.py index f6202d3bd6c..43822163c39 100644 --- a/kyu_8/formatting_decimal_places_0/two_decimal_places.py +++ b/kyu_8/formatting_decimal_places_0/two_decimal_places.py @@ -1,5 +1,6 @@ """ -Solution for -> Formatting decimal places #0 +Solution for -> Formatting decimal places #0. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def two_decimal_places(n: float) -> float: """ + Convert a number into decimal. + Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid From 477fc50ae9a52a8b553cf3c8066fbba3649b8743 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:05:30 -0800 Subject: [PATCH 14/81] Grasshopper --- .../grasshopper_check_for_factor/__init__.py | 1 + .../check_for_factor.py | 6 +- .../test_check_for_factor.py | 68 ++++++++----------- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/kyu_8/grasshopper_check_for_factor/__init__.py b/kyu_8/grasshopper_check_for_factor/__init__.py index e69de29bb2d..e8573f8e858 100644 --- a/kyu_8/grasshopper_check_for_factor/__init__.py +++ b/kyu_8/grasshopper_check_for_factor/__init__.py @@ -0,0 +1 @@ +"""Grasshopper.""" diff --git a/kyu_8/grasshopper_check_for_factor/check_for_factor.py b/kyu_8/grasshopper_check_for_factor/check_for_factor.py index 9073809a97c..b22755abbf9 100644 --- a/kyu_8/grasshopper_check_for_factor/check_for_factor.py +++ b/kyu_8/grasshopper_check_for_factor/check_for_factor.py @@ -1,5 +1,6 @@ """ -Solution for -> Grasshopper - Check for factor +Solution for -> Grasshopper - Check for factor. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,7 @@ def check_for_factor(base: int, factor: int) -> bool: """ - This function should test if the - factor is a factor of base. + Check if the factor is a factor of base. Factors are numbers you can multiply together to get another number. diff --git a/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py b/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py index 52ace47678c..6b8597bb418 100644 --- a/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py +++ b/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py @@ -1,5 +1,6 @@ """ -Test for -> Grasshopper - Check for factor +Test for -> Grasshopper - Check for factor. + 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.grasshopper_check_for_factor.check_for_factor \ import check_for_factor @@ -29,11 +31,14 @@ name='Source/Kata') # pylint: disable=R0801 class CheckForFactorTestCase(unittest.TestCase): - """ - Testing check_for_factor function. - """ - - def test_check_for_factor_true(self): + """Testing check_for_factor function.""" + + @parameterized.expand([ + (10, 2, True), + (63, 7, True), + (2450, 5, True), + (24612, 3, True)]) + def test_check_for_factor_true(self, base, factor, expected): """ Testing check_for_factor function. @@ -49,28 +54,22 @@ def test_check_for_factor_true(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 with allure.step("Return true if it is a factor"): - data: tuple = ( - (10, 2, True), - (63, 7, True), - (2450, 5, True), - (24612, 3, True)) - - for base, factor, expected in data: - - print_log(base=base, - factor=factor, - expected=expected) - - self.assertEqual(expected, - check_for_factor(base, factor)) - - def test_check_for_factor_false(self): + print_log(base=base, factor=factor, expected=expected) + self.assertEqual(expected, check_for_factor(base, factor)) + + @parameterized.expand([ + (9, 2, False), + (653, 7, False), + (2453, 5, False), + (24617, 3, False)]) + def test_check_for_factor_false(self, base, factor, expected): """ Testing check_for_factor function. @@ -86,23 +85,12 @@ def test_check_for_factor_false(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 with allure.step("Return false if it is not a factor"): - data: tuple = ( - (9, 2, False), - (653, 7, False), - (2453, 5, False), - (24617, 3, False)) - - for base, factor, expected in data: - - print_log(base=base, - factor=factor, - expected=expected) - - self.assertEqual(expected, - check_for_factor(base, factor)) + print_log(base=base, factor=factor, expected=expected) + self.assertEqual(expected, check_for_factor(base, factor)) From a0dd26595fb3708c13dd945ada1b8b379c804314 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:10:40 -0800 Subject: [PATCH 15/81] # Grasshopper - Messi goals function --- .../__init__.py | 1 + .../messi_goals_function.py | 5 ++++- .../test_messi_goals_function.py | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/kyu_8/grasshopper_messi_goals_function/__init__.py b/kyu_8/grasshopper_messi_goals_function/__init__.py index e69de29bb2d..b041eb78383 100644 --- a/kyu_8/grasshopper_messi_goals_function/__init__.py +++ b/kyu_8/grasshopper_messi_goals_function/__init__.py @@ -0,0 +1 @@ +"""Grasshopper - Messi goals function.""" diff --git a/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py b/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py index 439037ca19d..8891f8333af 100644 --- a/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py +++ b/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py @@ -1,5 +1,6 @@ """ -Solution for -> Messi goals function +Solution for -> Messi goals function. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def goals(la_liga: int, copa_delrey: int, champions_league: int) -> int: """ + Goals function. + The function returns Messi's total number of goals in all three leagues: - LaLiga diff --git a/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py b/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py index a69045f494d..faad955dd3d 100644 --- a/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py +++ b/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py @@ -1,5 +1,6 @@ """ -Test for -> Messi goals function +Test for -> Messi goals function. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,14 +27,15 @@ name='Source/Kata') # pylint: enable=R0801 class GoalsTestCase(unittest.TestCase): - """ - Testing goals function - """ + """Testing goals function.""" def test_goals(self): """ - Verify that the function returns Messi's - total number of goals in all three leagues. + Testing 'goals' function with various test data. + + Verify that the function returns Messi's total + number of goals in all three leagues. + :return: """ # pylint: disable=R0801 @@ -41,8 +43,9 @@ def test_goals(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 From 19e631f47f1242af41c35ddb86b3854f2f5538ae Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:17:14 -0800 Subject: [PATCH 16/81] Personalized greeting --- .../__init__.py | 1 + .../grasshopper_personalized_message.py | 7 ++++--- .../test_grasshopper_personalized_message.py | 21 ++++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/kyu_8/grasshopper_personalized_message/__init__.py b/kyu_8/grasshopper_personalized_message/__init__.py index e69de29bb2d..491c5af033c 100644 --- a/kyu_8/grasshopper_personalized_message/__init__.py +++ b/kyu_8/grasshopper_personalized_message/__init__.py @@ -0,0 +1 @@ +"""Grasshopper - Personalized Message.""" diff --git a/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py b/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py index 32e43086b0f..2ffbc91f663 100644 --- a/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py +++ b/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py @@ -1,5 +1,6 @@ """ -Solution for -> Personalized greeting +Solution for -> Personalized greeting. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,9 +8,9 @@ def greet(name: str, owner: str) -> str: """ - Function that gives a personalized greeting. - This function takes two parameters: name and owner. + Return a personalized greeting. + This function takes two parameters: name and owner. :param name: str :param owner: str :return: diff --git a/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py b/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py index c7ebc2db024..a6ebc4e21a2 100644 --- a/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py +++ b/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py @@ -1,5 +1,6 @@ """ -Test for -> Personalized greeting +Test for -> Personalized greeting. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -23,18 +24,17 @@ @allure.tag('FUNDAMENTALS', 'CONDITIONAL STATEMENTS', 'CONTROL FLOW') -@allure.link(url='https://www.codewars.com/kata/5772da22b89313a4d50012f7', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5772da22b89313a4d50012f7', + name='Source/Kata') # pylint: enable=R0801 class GreetTestCase(unittest.TestCase): - """ - Testing greet function - """ + """Testing greet function.""" def test_greet(self): """ - Use conditionals to to verify that greet - function returns the proper message. + Conditionals tests to verify that greet function returns the proper message. + :return: """ # pylint: disable=R0801 @@ -43,8 +43,9 @@ def test_greet(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 From 097e59ca172e3f260ed980d435c05910ce3c72a2 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:21:58 -0800 Subject: [PATCH 17/81] Grasshopper - Summation --- kyu_8/grasshopper_summation/__init__.py | 1 + kyu_8/grasshopper_summation/summation.py | 11 ++--- kyu_8/grasshopper_summation/test_summation.py | 42 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/kyu_8/grasshopper_summation/__init__.py b/kyu_8/grasshopper_summation/__init__.py index e69de29bb2d..1afc95ba7c6 100644 --- a/kyu_8/grasshopper_summation/__init__.py +++ b/kyu_8/grasshopper_summation/__init__.py @@ -0,0 +1 @@ +"""Grasshopper - Summation.""" diff --git a/kyu_8/grasshopper_summation/summation.py b/kyu_8/grasshopper_summation/summation.py index 244c2dd01d4..b0d76af18ef 100644 --- a/kyu_8/grasshopper_summation/summation.py +++ b/kyu_8/grasshopper_summation/summation.py @@ -1,5 +1,6 @@ """ -Solution for -> Grasshopper - Summation +Solution for -> Grasshopper - Summation. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,12 +8,12 @@ def summation(num: int) -> int: """ - A program that finds the summation of every - number from 1 to num. + Find the summation of every number from 1 to num. + The number will always be a positive integer greater than 0. - :param num: - :return: + :param num: int + :return: int """ result: int = 0 for i in range(1, num + 1): diff --git a/kyu_8/grasshopper_summation/test_summation.py b/kyu_8/grasshopper_summation/test_summation.py index 888f66a3f9b..9463ac9c165 100644 --- a/kyu_8/grasshopper_summation/test_summation.py +++ b/kyu_8/grasshopper_summation/test_summation.py @@ -1,5 +1,6 @@ """ -Test for -> Grasshopper - Summation +Test for -> Grasshopper - Summation. + 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.grasshopper_summation.summation import summation @@ -28,14 +30,18 @@ name='Source/Kata') # pylint: enable=R0801 class SummationTestCase(unittest.TestCase): - """ - Testing summation function - """ + """Testing summation function.""" - def test_summation(self): + @parameterized.expand([ + (1, 1), + (8, 36), + (22, 253), + (100, 5050), + (213, 22791)]) + def test_summation(self, num, expected): """ - Testing summation function - with various test inputs + Testing summation function with various test inputs. + :return: """ # pylint: disable=R0801 @@ -43,21 +49,13 @@ def test_summation(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

") # pylint: enable=R0801 - with allure.step("Enter number and verify the output"): - test_data: tuple = ( - (1, 1), - (8, 36), - (22, 253), - (100, 5050), - (213, 22791)) - - for d in test_data: - num: int = d[0] - expected: int = d[1] - print_log(num=num, expected=expected) - self.assertEqual(summation(num), expected) + with allure.step(f"Enter a number: {num} " + f"and verify the expected output: {expected}."): + print_log(num=num, expected=expected) + self.assertEqual(summation(num), expected) From 033aef3a017ca38e50a6aa283bb860d0a6f3ea0f Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:39:31 -0800 Subject: [PATCH 18/81] # Greek Sort --- kyu_8/greek_sort/__init__.py | 1 + kyu_8/greek_sort/evaluator.py | 8 +++- kyu_8/greek_sort/greek_comparator.py | 7 ++- kyu_8/greek_sort/test_greek_comparator.py | 54 +++++++++++------------ 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/kyu_8/greek_sort/__init__.py b/kyu_8/greek_sort/__init__.py index e69de29bb2d..c7b87d9e076 100644 --- a/kyu_8/greek_sort/__init__.py +++ b/kyu_8/greek_sort/__init__.py @@ -0,0 +1 @@ +"""Greek Sort.""" diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index ed4a7f7f3f2..87ee1fa7f28 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -1,11 +1,15 @@ """ -Evaluates the expression +Evaluator function for -> Greek Sort. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan """ def evaluator(result: int, expected: str) -> bool: """ - Evaluator + Evaluator function. + :param result: int :param expected: str :return: bool diff --git a/kyu_8/greek_sort/greek_comparator.py b/kyu_8/greek_sort/greek_comparator.py index c3c6cb9665c..3be8ac276f6 100644 --- a/kyu_8/greek_sort/greek_comparator.py +++ b/kyu_8/greek_sort/greek_comparator.py @@ -1,5 +1,6 @@ """ -Solution for -> Greek Sort +Solution for -> Greek Sort. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -15,10 +16,12 @@ def greek_comparator(lhs: str, rhs: str) -> int: """ + Greek comparator function. + A custom comparison function of two arguments (iterable elements) which should return a negative, zero or positive number depending on whether the first argument is considered smaller than, equal to, - or larger than the second argument + or larger than the second argument. :param lhs: str :param rhs: str :return: int diff --git a/kyu_8/greek_sort/test_greek_comparator.py b/kyu_8/greek_sort/test_greek_comparator.py index e2f70debdf6..5213b0fc477 100644 --- a/kyu_8/greek_sort/test_greek_comparator.py +++ b/kyu_8/greek_sort/test_greek_comparator.py @@ -1,5 +1,6 @@ """ -Test for -> Greek Sort +Test for -> Greek Sort. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from kyu_8.greek_sort.greek_comparator import greek_comparator from kyu_8.greek_sort.evaluator import evaluator from utils.log_func import print_log @@ -24,14 +26,16 @@ url='https://www.codewars.com/kata/56bc1acf66a2abc891000561', name='Source/Kata') class GreekComparatorTestCase(unittest.TestCase): - """ - Testing greek_comparator function - """ + """Testing greek_comparator function.""" - def test_greek_comparator(self): + @parameterized.expand([ + ('alpha', 'beta', '< 0'), + ('psi', 'psi', '== 0'), + ('upsilon', 'rho', '> 0')]) + def test_greek_comparator(self, lhs, rhs, expected): """ - Testing greek_comparator function - with various test inputs + Testing greek_comparator function with various test inputs. + :return: """ # pylint: disable=R0801 @@ -39,8 +43,9 @@ def test_greek_comparator(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' "

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)) From 718d2c7afdba14c85f0c871e919df4d68c93cbd1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 03:40:41 -0800 Subject: [PATCH 19/81] Update __init__.py --- kyu_8/find_the_first_non_consecutive_number/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5d551d5ef4e..97e0a5e54d6 100644 --- a/kyu_8/find_the_first_non_consecutive_number/__init__.py +++ b/kyu_8/find_the_first_non_consecutive_number/__init__.py @@ -1 +1 @@ -"""Find the first non-consecutive number.""" \ No newline at end of file +"""Find the first non-consecutive number.""" From 07fa235d218c50bfdc5678a05860e231bae1b9c1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:24:37 -0800 Subject: [PATCH 20/81] closest_elevator --- kyu_8/README.md | 79 ++++++++++--------- kyu_8/closest_elevator/README.md | 30 +++++++ kyu_8/closest_elevator/__init__.py | 1 + kyu_8/closest_elevator/closest_elevator.py | 24 ++++++ .../closest_elevator/test_closest_elevator.py | 62 +++++++++++++++ 5 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 kyu_8/closest_elevator/README.md create mode 100644 kyu_8/closest_elevator/__init__.py create mode 100644 kyu_8/closest_elevator/closest_elevator.py create mode 100644 kyu_8/closest_elevator/test_closest_elevator.py 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/closest_elevator/README.md b/kyu_8/closest_elevator/README.md new file mode 100644 index 00000000000..51e1fa33e81 --- /dev/null +++ b/kyu_8/closest_elevator/README.md @@ -0,0 +1,30 @@ +# Closest elevator + +## Description + +Given 2 elevators (named "left" and "right") in a building with 3 floors +(numbered 0 to 2), write a function accepting 3 arguments (in order): + +`left` - The current floor of the left elevator +`right` - The current floor of the right elevator +`call` - The floor that called an elevator + +It should return the name of the elevator closest to the called floor ("left"/"right"). + +In the case where both elevators are equally distant from the called floor, +choose the elevator to the right. + +You can assume that the inputs will always be valid integers between 0-2. + +## Examples + +``` +left right call result + 0 1 0 "left" + 0 1 1 "right" + 0 1 2 "right" + 0 0 0 "right" + 0 2 1 "right" +``` + +[Source](https://www.codewars.com/kata/5c374b346a5d0f77af500a5a) \ No newline at end of file diff --git a/kyu_8/closest_elevator/__init__.py b/kyu_8/closest_elevator/__init__.py new file mode 100644 index 00000000000..7eaf34320c3 --- /dev/null +++ b/kyu_8/closest_elevator/__init__.py @@ -0,0 +1 @@ +"""Closest elevator.""" diff --git a/kyu_8/closest_elevator/closest_elevator.py b/kyu_8/closest_elevator/closest_elevator.py new file mode 100644 index 00000000000..d7a14647c98 --- /dev/null +++ b/kyu_8/closest_elevator/closest_elevator.py @@ -0,0 +1,24 @@ +""" +Solution for -> Closest elevator. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +def elevator(left: int, right: int, call: int) -> str: + """ + Return closest elevator number. + + :param left: int + :param right: int + :param call: int + :return: str + """ + if right == left == call: + return 'right' + + if left == call or abs(call - left) < abs(call - right): + return 'left' + + return 'right' + diff --git a/kyu_8/closest_elevator/test_closest_elevator.py b/kyu_8/closest_elevator/test_closest_elevator.py new file mode 100644 index 00000000000..fb6e3bc0873 --- /dev/null +++ b/kyu_8/closest_elevator/test_closest_elevator.py @@ -0,0 +1,62 @@ +""" +Test for -> Closest elevator. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +# Algorithms + +import unittest +import allure +from parameterized import parameterized +from utils.log_func import print_log +from kyu_8.closest_elevator.closest_elevator import elevator + + +# pylint: disable=R0801 +@allure.epic('8 kyu') +@allure.parent_suite('Beginner') +@allure.suite("Data Structures") +@allure.sub_suite("Unit Tests") +@allure.feature("Lists") +@allure.story('Closest elevator') +@allure.tag('FUNDAMENTALS', + 'ALGORITHMS') +@allure.link( + url='https://www.codewars.com/kata/5c374b346a5d0f77af500a5a', + name='Source/Kata') +# pylint: enable=R0801 +class ClosestElevatorTestCase(unittest.TestCase): + """Test elevator function.""" + + @parameterized.expand([ + ((0, 1, 0), "left"), + ((0, 1, 1), "right"), + ((0, 1, 2), "right"), + ((0, 0, 0), "right"), + ((0, 2, 1), "right")]) + def test_elevator_basic(self, elevators, expected): + """ + Testing 'elevator' function with various test data. + + :return: + """ + # pylint: disable=R0801 + allure.dynamic.title("Testing elevator function") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # pylint: enable=R0801 + with allure.step(f"Enter test data: {elevators} " + f"and verify the expected output: {expected}."): + left, right, call = elevators + result: str = elevator(left, right, call) + print_log(expected=expected, left=left, right=right, call=call) + message: str = f'elevators: {elevators}, result: {result}, expected: {expected}' + self.assertEqual(expected, result, msg=message) From aa02db4e8d1a5a634aacb28eb35102d3328caf04 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:26:24 -0800 Subject: [PATCH 21/81] Update closest_elevator.py Using config file /home/runner/work/codewars/codewars/.pylintrc ************* Module kyu_8.closest_elevator.closest_elevator kyu_8/closest_elevator/closest_elevator.py:24:0: C0305: Trailing newlines (trailing-newlines) --- kyu_8/closest_elevator/closest_elevator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/closest_elevator/closest_elevator.py b/kyu_8/closest_elevator/closest_elevator.py index d7a14647c98..3a04743db19 100644 --- a/kyu_8/closest_elevator/closest_elevator.py +++ b/kyu_8/closest_elevator/closest_elevator.py @@ -21,4 +21,3 @@ def elevator(left: int, right: int, call: int) -> str: return 'left' return 'right' - From 2e5bc5ab72b314e268a2377e277bfd2f1f93bc8e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:27:44 -0800 Subject: [PATCH 22/81] Update requirements.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issues to fix by upgrading dependencies: Upgrade jinja2@3.1.4 to jinja2@3.1.5 to fix ✗ Template Injection (new) [Medium Severity][https://security.snyk.io/vuln/SNYK-PYTHON-JINJA2-8548181] in jinja2@3.1.4 introduced by jinja2@3.1.4 and 2 other path(s) ✗ Improper Neutralization (new) [Medium Severity][https://security.snyk.io/vuln/SNYK-PYTHON-JINJA2-8548987] in jinja2@3.1.4 introduced by jinja2@3.1.4 and 2 other path(s) --- requirements.txt | Bin 2808 -> 2808 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644 GIT binary patch delta 14 Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM delta 14 Vcmew%`a^UB6APosW@eVJYyc?^1iJtL From 8e5724aa2a5e2349dd40ac7bdcf474f61b9d4402 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:33:30 -0800 Subject: [PATCH 23/81] Update requirements.txt --- requirements.txt | Bin 2808 -> 2808 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644 GIT binary patch delta 14 Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM delta 14 Vcmew%`a^UB6APosW@eVJYyc?^1iJtL From 07c185194fafa24406c8848740e1489f52982dce Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:50:24 -0800 Subject: [PATCH 24/81] # Holiday VI - Shark Pontoon --- kyu_8/holiday_vi_shark_pontoon/__init__.py | 1 + kyu_8/holiday_vi_shark_pontoon/shark.py | 6 ++++-- kyu_8/holiday_vi_shark_pontoon/test_shark.py | 16 +++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) 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 From d20c550085305dd2e1d6070c75e98a2c28de8f3d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 05:00:15 -0800 Subject: [PATCH 25/81] kyu_8 docs --- docs/kyu_8/kyu_8.closest_elevator.rst | 32 +++++++++++++++++++++++++++ docs/kyu_8/kyu_8.greek_sort.rst | 10 ++++----- docs/kyu_8/kyu_8.rst | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 docs/kyu_8/kyu_8.closest_elevator.rst 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..de518e18f07 100644 --- a/docs/kyu_8/kyu_8.rst +++ b/docs/kyu_8/kyu_8.rst @@ -7,10 +7,10 @@ Subpackages .. toctree:: :maxdepth: 4 - kyu_8.readme 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 From 6d62247f082be9c2e769394bb02f3f0f6ecb4c99 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 05:07:38 -0800 Subject: [PATCH 26/81] # Is it a palindrome --- kyu_8/is_it_a_palindrome/__init__.py | 1 + kyu_8/is_it_a_palindrome/is_palindrome.py | 7 ++- .../is_it_a_palindrome/test_is_palindrome.py | 52 +++++++++---------- 3 files changed, 32 insertions(+), 28 deletions(-) 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): '' '

Test Description:

' - "

") - - with allure.step("Enter test string and verify the output"): - test_data: tuple = ( - ('a', True), - ('aba', True), - ('Abba', True), - ('malam', True), - ('walter', False), - ('kodok', True), - ('Kasue', False), - ('NdjXglGnYGKhQtuAcxNWFwVRZZDMrFmiOPMZsvr', False), - ('XqmUTaAmrrYitgNwkCwaWdFYsEhfIeOohViba', False), - ('ZtItThFBUPCSCbtcUfDwXzyajhRIWioUHpVzN', False), - ('XqNeuBjbshHwqjoUNGHhVRolqxWRRWYYbN', False)) + "

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)) From 3e56bf32baffef0cdcfd3a711c90c7b211387eec Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 05:11:24 -0800 Subject: [PATCH 27/81] # MakeUpperCase --- kyu_8/make_upper_case/__init__.py | 1 + kyu_8/make_upper_case/make_upper_case.py | 6 ++++-- kyu_8/make_upper_case/test_make_upper_case.py | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) 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..29dc55c42db 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. + Function that 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( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

") + "

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" From 58114cdabc5912d8c574f3f4e038ce08305b979e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:18:47 -0800 Subject: [PATCH 28/81] multiply --- kyu_8/multiply/__init__.py | 1 + kyu_8/multiply/multiply.py | 15 ++++++--------- kyu_8/multiply/test_multiply.py | 11 +++++------ 3 files changed, 12 insertions(+), 15 deletions(-) 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 From aec5c893dbc8dfa3a7b2c7a16c8da37368f5ae52 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:25:38 -0800 Subject: [PATCH 29/81] My head is at the wrong end. --- kyu_8/my_head_is_at_the_wrong_end/__init__.py | 1 + .../fix_the_meerkat.py | 11 ++--- .../test_fix_the_meerkat.py | 49 ++++++++++--------- 3 files changed, 31 insertions(+), 30 deletions(-) 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) From 175679b2a68d63f5f3503a3c6858f86c1c73f6c3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:29:22 -0800 Subject: [PATCH 30/81] Remove First and Last Character --- kyu_8/remove_first_and_last_character/__init__.py | 1 + .../remove_first_and_last_character/remove_char.py | 10 ++++------ .../test_remove_char.py | 13 ++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) 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 From ec31847763b5bbc73922177cd0332c1a78704694 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:33:50 -0800 Subject: [PATCH 31/81] Remove String Spaces. --- kyu_8/remove_string_spaces/__init__.py | 1 + kyu_8/remove_string_spaces/remove_string_spaces.py | 7 ++++--- .../remove_string_spaces/test_remove_string_spaces.py | 11 +++++------ 3 files changed, 10 insertions(+), 9 deletions(-) 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 From f72d3f3fb94a7f3b78f46bea1cc002d699c6c668 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:36:26 -0800 Subject: [PATCH 32/81] Update kyu_8.rst checking consistency... /home/docs/checkouts/readthedocs.org/user_builds/codewars/checkouts/573/docs/kyu_8/kyu_8.readme.rst: WARNING: document isn't included in any toctree --- docs/kyu_8/kyu_8.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/kyu_8/kyu_8.rst b/docs/kyu_8/kyu_8.rst index de518e18f07..a144d283b9c 100644 --- a/docs/kyu_8/kyu_8.rst +++ b/docs/kyu_8/kyu_8.rst @@ -7,6 +7,7 @@ Subpackages .. toctree:: :maxdepth: 4 + kyu_8.readme kyu_8.alternating_case kyu_8.century_from_year kyu_8.check_the_exam From 8ea0a8cd3859adb15da1e4d722b39fd6c106ad69 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:42:00 -0800 Subject: [PATCH 33/81] Reversed Strings. --- kyu_8/reversed_strings/__init__.py | 1 + kyu_8/reversed_strings/reversed_strings.py | 6 ++++-- kyu_8/reversed_strings/test_reversed_strings.py | 16 +++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) 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 From ba6be03e55f96f17e269903ccd2279d0a3536fc2 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:49:43 -0800 Subject: [PATCH 34/81] L1: Set Alarm --- kyu_8/set_alarm/__init__.py | 1 + kyu_8/set_alarm/set_alarm.py | 16 ++------ kyu_8/set_alarm/test_set_alarm.py | 62 +++++++++++++++++-------------- 3 files changed, 39 insertions(+), 40 deletions(-) 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..8343922b702 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 @@ -30,7 +32,20 @@ class SetAlarmTestCase(unittest.TestCase): 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. @@ -55,31 +70,22 @@ def test_set_alarm(self): '' '

Test Description:

' - "

") + "

" + "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
' + "

") # pylint: enable=R0801 with allure.step("Enter test data and verify the output"): - test_data: tuple = ( - ((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")) - - for test_input, expected, msg in test_data: - employed: bool = test_input[0] - vacation: bool = test_input[1] - - print_log(employed=employed, - vacation=vacation, - expected=expected) - - self.assertEqual(expected, - set_alarm(employed, vacation), - msg) + employed, vacation = test_input + print_log(employed=employed, vacation=vacation, expected=expected) + self.assertEqual(expected, set_alarm(employed, vacation), msg) From 07a08499afe696fba2edc5a2ee56d85ae7fd79dc Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:52:56 -0800 Subject: [PATCH 35/81] Surface Area and Volume of a Box. --- kyu_8/surface_area_and_volume_of_box/__init__.py | 1 + kyu_8/surface_area_and_volume_of_box/get_size.py | 7 ++++--- kyu_8/surface_area_and_volume_of_box/test_get_size.py | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kyu_8/surface_area_and_volume_of_box/__init__.py b/kyu_8/surface_area_and_volume_of_box/__init__.py index e69de29bb2d..58f15b59258 100644 --- a/kyu_8/surface_area_and_volume_of_box/__init__.py +++ b/kyu_8/surface_area_and_volume_of_box/__init__.py @@ -0,0 +1 @@ +"""Surface Area and Volume of a Box.""" diff --git a/kyu_8/surface_area_and_volume_of_box/get_size.py b/kyu_8/surface_area_and_volume_of_box/get_size.py index 33f8159f569..7361384429a 100644 --- a/kyu_8/surface_area_and_volume_of_box/get_size.py +++ b/kyu_8/surface_area_and_volume_of_box/get_size.py @@ -1,5 +1,6 @@ """ -Solution for -> Surface Area and Volume of a Box +Solution for -> Surface Area and Volume of a Box. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,8 @@ def get_size(w: int, h: int, d: int) -> list: """ - Write a function that returns the total surface - area and volume of a box as an array: [area, volume] + Return the total surface area and volume of a box as an array. + :param w: :param h: :param d: diff --git a/kyu_8/surface_area_and_volume_of_box/test_get_size.py b/kyu_8/surface_area_and_volume_of_box/test_get_size.py index 90d3dc07ff7..b914d568173 100644 --- a/kyu_8/surface_area_and_volume_of_box/test_get_size.py +++ b/kyu_8/surface_area_and_volume_of_box/test_get_size.py @@ -1,5 +1,6 @@ """ -Test for -> Surface Area and Volume of a Box +Test for -> Surface Area and Volume of a Box. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,13 +30,12 @@ name='Source/Kata') # pylint: enable=R0801 class GetSizeTestCase(unittest.TestCase): - """ - Testing get_size function - """ + """Testing get_size function.""" def test_get_size(self): """ - Testing get_size function with various inputs + Testing get_size function with various inputs. + :return: """ # pylint: disable=R0801 From 738530bb8bfb1b1a4180edf005dfe9baa9f1171e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:55:32 -0800 Subject: [PATCH 36/81] Swap Values. --- kyu_8/swap_values/__init__.py | 1 + kyu_8/swap_values/swap_values.py | 6 ++++-- kyu_8/swap_values/test_swap_values.py | 12 ++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kyu_8/swap_values/__init__.py b/kyu_8/swap_values/__init__.py index e69de29bb2d..b650c89caf8 100644 --- a/kyu_8/swap_values/__init__.py +++ b/kyu_8/swap_values/__init__.py @@ -0,0 +1 @@ +"""Swap Values.""" diff --git a/kyu_8/swap_values/swap_values.py b/kyu_8/swap_values/swap_values.py index 270bfe2619d..72c7d990dd2 100644 --- a/kyu_8/swap_values/swap_values.py +++ b/kyu_8/swap_values/swap_values.py @@ -1,5 +1,6 @@ """ -Solution for -> Swap Values +Solution for -> Swap Values. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,8 @@ def swap_values(args: list) -> None: """ - Swap values + Swap values. + :param args: :return: """ diff --git a/kyu_8/swap_values/test_swap_values.py b/kyu_8/swap_values/test_swap_values.py index 76cb92557c9..8a9b5ebded0 100644 --- a/kyu_8/swap_values/test_swap_values.py +++ b/kyu_8/swap_values/test_swap_values.py @@ -1,5 +1,6 @@ """ -Test for -> Swap Values +Test for -> Swap Values. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,13 +28,13 @@ name='Source/Kata') # pylint: enable-msg=R0801 class SwapValuesTestCase(unittest.TestCase): - """ - Testing swap_values function - """ + """Testing swap_values function.""" def test_swap_values(self): """ - Testing swap_values function + Testing swap_values function with various test data. + + :return: """ # pylint: disable=R0801 allure.dynamic.title("Testing swap_values function") @@ -49,7 +50,6 @@ def test_swap_values(self): swap: list = [1, 2] expected: list = [2, 1] swap_values(swap) - print_log(list=swap, expected=expected) self.assertEqual(swap[0], 2) self.assertEqual(swap[1], 1) From 058650e7162fb35d040876bc682e0a3590abc618 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:58:59 -0800 Subject: [PATCH 37/81] Grasshopper - Terminal game move function. --- kyu_8/terminal_game_move_function/__init__.py | 1 + .../terminal_game_move_function.py | 11 +++++++---- .../test_terminal_game_move_function.py | 17 ++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/kyu_8/terminal_game_move_function/__init__.py b/kyu_8/terminal_game_move_function/__init__.py index e69de29bb2d..7b2d7af469e 100644 --- a/kyu_8/terminal_game_move_function/__init__.py +++ b/kyu_8/terminal_game_move_function/__init__.py @@ -0,0 +1 @@ +"""Grasshopper - Terminal game move function.""" diff --git a/kyu_8/terminal_game_move_function/terminal_game_move_function.py b/kyu_8/terminal_game_move_function/terminal_game_move_function.py index b57f9c4196f..34e3630693c 100644 --- a/kyu_8/terminal_game_move_function/terminal_game_move_function.py +++ b/kyu_8/terminal_game_move_function/terminal_game_move_function.py @@ -1,5 +1,6 @@ """ -Solution for -> Grasshopper - Terminal game move function +Solution for -> Grasshopper - Terminal game move function. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,11 +8,13 @@ def move(position: int, roll: int) -> int: """ + 'move' function. + A function for the terminal game that takes the current position of the hero and the roll (1-6) and return the new position. - :param position: - :param roll: - :return: + :param position: int + :param roll: int + :return: int """ return position + (roll * 2) diff --git a/kyu_8/terminal_game_move_function/test_terminal_game_move_function.py b/kyu_8/terminal_game_move_function/test_terminal_game_move_function.py index f236d17e6bd..dc8942074c8 100644 --- a/kyu_8/terminal_game_move_function/test_terminal_game_move_function.py +++ b/kyu_8/terminal_game_move_function/test_terminal_game_move_function.py @@ -1,5 +1,6 @@ """ -Test for -> Grasshopper - Terminal game move function +Test for -> Grasshopper - Terminal game move function. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,17 +27,12 @@ name='Source/Kata') # pylint: enable=R0801 class MoveTestCase(unittest.TestCase): - """ - Testing move function - """ + """Testing move function.""" def test_move(self): """ - The player rolls the dice and moves the number - of spaces indicated by the dice two times. + Testing 'move' function with various test data. - Pass position and roll and compare the output - to the expected result :return: """ # pylint: disable=R0801 @@ -47,7 +43,10 @@ def test_move(self): '' '

Test Description:

' - "

") + "

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 From f7652d870c7e8682d02bb2c20e78cefbacae25e6 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:03:43 -0800 Subject: [PATCH 38/81] The Feast of Many Beasts. --- kyu_8/the_feast_of_many_beasts/__init__.py | 1 + kyu_8/the_feast_of_many_beasts/feast.py | 7 ++-- kyu_8/the_feast_of_many_beasts/test_feast.py | 38 +++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) 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): '' '

Test Description:

' - "

") + "

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"): From ea578389c99fa8544b9048df6732b2ff9d06f274 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:07:52 -0800 Subject: [PATCH 39/81] Third Angle of a Triangle. --- kyu_8/third_angle_of_triangle/__init__.py | 1 + .../test_third_angle_of_triangle.py | 38 ++++++------------- .../third_angle_of_triangle.py | 5 ++- 3 files changed, 16 insertions(+), 28 deletions(-) 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..353637dacae 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 """ @@ -26,14 +27,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class OtherAngleTestCase(unittest.TestCase): - """ - Testing other_angle - """ + """Testing other_angle function.""" def test_other_angle(self): """ - 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,28 +43,21 @@ def test_other_angle(self): '' '

Test Description:

' - "

") + "

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) - + 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) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) self.assertEqual(other_angle(60, 60), 60) @@ -73,20 +65,12 @@ def test_other_angle(self): a = 43 b = 78 expected = 59 - - print_log(a=a, - b=b, - expected=expected) - + 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. From 36b83c29fe81c9964662da8cf5a146af1d576864 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:13:09 -0800 Subject: [PATCH 40/81] Well of Ideas - Easy Version --- kyu_8/well_of_ideas_easy_version/__init__.py | 1 + .../test_well_of_ideas_easy_version.py | 30 +++++++++---------- .../well_of_ideas_easy_version.py | 8 ++--- 3 files changed, 20 insertions(+), 19 deletions(-) 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( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

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..c8a19a9490d 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 """ From 6b9f1b33d6fd806d2c0aa55f8b8d6bb6571645e5 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:17:39 -0800 Subject: [PATCH 41/81] Will there be enough space?. --- kyu_8/will_there_be_enough_space/__init__.py | 1 + kyu_8/will_there_be_enough_space/enough.py | 3 +- .../will_there_be_enough_space/test_enough.py | 55 ++++++++----------- 3 files changed, 27 insertions(+), 32 deletions(-) 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..3ed26defd6f 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 """ 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( '

Codewars badge:

' '' '

Test Description:

' - "

") + "

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)) From 309a6ef0d8e131161be12c69dbd41bfc0e29d9ce Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:22:43 -0800 Subject: [PATCH 42/81] # Will you make it --- kyu_8/will_you_make_it/README.md | 2 +- kyu_8/will_you_make_it/__init__.py | 1 + kyu_8/will_you_make_it/test_zero_fuel.py | 49 +++++++++++------------- kyu_8/will_you_make_it/zero_fuel.py | 10 +++-- 4 files changed, 31 insertions(+), 31 deletions(-) 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( '

Codewars badge:

' - '' + '' '

Test Description:

' "

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 From 746f6d160bb312ac31de0cf1ac1845728f5f4e09 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:29:35 -0800 Subject: [PATCH 43/81] A wolf in sheep's clothing. --- kyu_8/wolf_in_sheep_clothing/__init__.py | 1 + .../test_wolf_in_sheep_clothing.py | 28 +++++++++++++------ .../wolf_in_sheep_clothing.py | 6 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) 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): '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

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". From 5083d4504bc8dca7c59f15a91d803b3f96c92086 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:36:31 -0800 Subject: [PATCH 44/81] # Keep Hydrated --- kyu_8/keep_hydrated/__init__.py | 1 + kyu_8/keep_hydrated/keep_hydrated.py | 5 ++- kyu_8/keep_hydrated/test_keep_hydrated.py | 48 +++++++++++++---------- 3 files changed, 33 insertions(+), 21 deletions(-) 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): '' '

Test Description:

' - "

") + "

" + "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) From fd0ddb59f22d921f530c518920692a964099f809 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:39:01 -0800 Subject: [PATCH 45/81] Update evaluator.py kyu_8/greek_sort/evaluator.py:10 in public function `evaluator`: D401: First line should be in imperative mood (perhaps 'Evaluate', not 'Evaluator') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index 87ee1fa7f28..f32ba347cc9 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - Evaluator function. + 'evaluator' function. :param result: int :param expected: str From d08cdaac2d08001162f5e2c8ac11b895b8de9f86 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:39:52 -0800 Subject: [PATCH 46/81] Update make_upper_case.py kyu_8/make_upper_case/make_upper_case.py:10 in public function `make_upper_case`: D401: First line should be in imperative mood; try rephrasing (found 'Function') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/make_upper_case/make_upper_case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/make_upper_case/make_upper_case.py b/kyu_8/make_upper_case/make_upper_case.py index 29dc55c42db..b2dd792edbb 100644 --- a/kyu_8/make_upper_case/make_upper_case.py +++ b/kyu_8/make_upper_case/make_upper_case.py @@ -8,7 +8,7 @@ def make_upper_case(s: str) -> str: """ - Function that convert to UpperCase. + Convert to UpperCase. :param s: str :return: str From f32c8cdb607d33a280ca03fa9542fa22f0e358ca Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:40:57 -0800 Subject: [PATCH 47/81] Update enough.py kyu_8/will_there_be_enough_space/enough.py:10 in public function `enough`: D401: First line should be in imperative mood; try rephrasing (found 'The') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/will_there_be_enough_space/enough.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyu_8/will_there_be_enough_space/enough.py b/kyu_8/will_there_be_enough_space/enough.py index 3ed26defd6f..c320e23d1e7 100644 --- a/kyu_8/will_there_be_enough_space/enough.py +++ b/kyu_8/will_there_be_enough_space/enough.py @@ -8,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. @@ -19,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 From aced1dbeddf112653683ae9e145b5163b8391539 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:45:14 -0800 Subject: [PATCH 48/81] keep_up_the_hoop kyu_8/keep_up_the_hoop/hoop_count.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/hoop_count.py:1 at module level: D400: First line should end with a period (not 'p') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D401: First line should be in imperative mood; try rephrasing (found 'A') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". kyu_8/keep_up_the_hoop/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/keep_up_the_hoop/test_hoop_count.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/test_hoop_count.py:1 at module level: D400: First line should end with a period (not 'p') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:28 in public class `HoopCountTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/keep_up_the_hoop/test_hoop_count.py:28 in public class `HoopCountTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:33 in public method `test_hoop_count_positive`: D400: First line should end with a period (not ')') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:66 in public method `test_hoop_count_negative`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/test_hoop_count.py:66 in public method `test_hoop_count_negative`: D400: First line should end with a period (not ')') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/keep_up_the_hoop/__init__.py | 1 + kyu_8/keep_up_the_hoop/hoop_count.py | 8 +++++--- kyu_8/keep_up_the_hoop/test_hoop_count.py | 19 +++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) 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): '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

Testing hoop_count function (negative).

") # pylint: enable=R0801 with allure.step("Enter n and verify the result"): n: int = 3 From 78a128e27cf12ed9da745b57446791be23ba96a3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:53:05 -0800 Subject: [PATCH 49/81] logical_calculator kyu_8/logical_calculator/test_logical_calculator.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:1 at module level: D400: First line should end with a period (not 'r') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:30 in public class `LogicalCalculatorTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/logical_calculator/test_logical_calculator.py:30 in public class `LogicalCalculatorTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:35 in public method `test_logical_calc_and`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:35 in public method `test_logical_calc_and`: D400: First line should end with a period (not 'l') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:99 in public method `test_logical_calc_or`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:99 in public method `test_logical_calc_or`: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:157 in public method `test_logical_calc_xor`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:157 in public method `test_logical_calc_xor`: D400: First line should end with a period (not 'a') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/logical_calculator/logical_calculator.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/logical_calculator.py:1 at module level: D400: First line should end with a period (not 'r') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/logical_calculator.py:9 in public function `logical_calc`: D401: First line should be in imperative mood (perhaps 'Calculate', not 'Calculates') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/logical_calculator/__init__.py | 1 + .../logical_calculator/logical_calculator.py | 3 +- .../test_logical_calculator.py | 42 +++++++++++-------- 3 files changed, 28 insertions(+), 18 deletions(-) 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..f3dda92d72c 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 """ 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( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

" + "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( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

") + "

XOR outputs true whenever the inputs differ.

") # pylint: enable=R0801 with allure.step('Pass an array with 2 members (positive)'): lst: list = [True, False] From 50e4ef2108082365f7b5592363459b67b4aa7e84 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:56:50 -0800 Subject: [PATCH 50/81] is_your_period_late kyu_8/is_your_period_late/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/is_your_period_late/test_is_your_period_late.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:1 at module level: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:30 in public class `PeriodIsLateTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/is_your_period_late/test_is_your_period_late.py:30 in public class `PeriodIsLateTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:35 in public method `test_period_is_late_positive`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:35 in public method `test_period_is_late_positive`: D400: First line should end with a period (not 's') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:98 in public method `test_period_is_late_negative`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:98 in public method `test_period_is_late_negative`: D400: First line should end with a period (not 's') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/is_your_period_late.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/is_your_period_late.py:1 at module level: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/is_your_period_late/__init__.py | 1 + .../is_your_period_late/is_your_period_late.py | 3 ++- .../test_is_your_period_late.py | 17 +++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) 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): '' '

Test Description:

' - "

") + "

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): '' '

Test Description:

' - "

") + "

Negative tests.

") # pylint: enable=R0801 with allure.step("Pass last, today and period length"): last: date = date(2016, 6, 13) From 8c1169305f3c4bbc032f949b5b050d90adafd41d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:59:48 -0800 Subject: [PATCH 51/81] set_alarm kyu_8/set_alarm/test_set_alarm.py:31 in public class `SetAlarmTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/set_alarm/test_set_alarm.py:31 in public class `SetAlarmTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/set_alarm/test_set_alarm.py:49 in public method `test_set_alarm`: D412: No blank lines allowed between a section header and its content ('Examples') --- kyu_8/set_alarm/test_set_alarm.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kyu_8/set_alarm/test_set_alarm.py b/kyu_8/set_alarm/test_set_alarm.py index 8343922b702..6e3d5820cb7 100644 --- a/kyu_8/set_alarm/test_set_alarm.py +++ b/kyu_8/set_alarm/test_set_alarm.py @@ -28,9 +28,7 @@ name='Source/Kata') # pylint: enable=R0801 class SetAlarmTestCase(unittest.TestCase): - """ - Testing set_alarm function - """ + """Testing set_alarm function.""" @parameterized.expand([ ((True, True), @@ -54,7 +52,7 @@ def test_set_alarm(self, test_input, expected, msg): under which you need to set an alarm). It should return false otherwise. - Examples: + Examples setAlarm(true, true) -> false setAlarm(false, true) -> false From 341a31f4e27032903f79ebe80091ff64d77fad66 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:01:24 -0800 Subject: [PATCH 52/81] Update test_set_alarm.py kyu_8/set_alarm/test_set_alarm.py:47 in public method `test_set_alarm`: D412: No blank lines allowed between a section header and its content ('Examples') --- kyu_8/set_alarm/test_set_alarm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kyu_8/set_alarm/test_set_alarm.py b/kyu_8/set_alarm/test_set_alarm.py index 6e3d5820cb7..0b0643f102f 100644 --- a/kyu_8/set_alarm/test_set_alarm.py +++ b/kyu_8/set_alarm/test_set_alarm.py @@ -52,8 +52,7 @@ def test_set_alarm(self, test_input, expected, msg): under which you need to set an alarm). It should return false otherwise. - Examples - + Examples: setAlarm(true, true) -> false setAlarm(false, true) -> false setAlarm(false, false) -> false From 6532bb53f6204d492f4e6de77c53e278dca0794e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:02:13 -0800 Subject: [PATCH 53/81] Update logical_calculator.py kyu_8/logical_calculator/logical_calculator.py:10 in public function `logical_calc`: D401: First line should be in imperative mood (perhaps 'Calculate', not 'Calculates') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/logical_calculator/logical_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/logical_calculator.py b/kyu_8/logical_calculator/logical_calculator.py index f3dda92d72c..39cfbe75614 100644 --- a/kyu_8/logical_calculator/logical_calculator.py +++ b/kyu_8/logical_calculator/logical_calculator.py @@ -8,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. From d908bcb9ca90643f4834007e9284289f56f5b6ca Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:03:15 -0800 Subject: [PATCH 54/81] Update check_exam.py kyu_8/check_the_exam/check_exam.py:37 in public function `char_processor`: D401: First line should be in imperative mood (perhaps 'Process', not 'Processing') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/check_the_exam/check_exam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/check_the_exam/check_exam.py b/kyu_8/check_the_exam/check_exam.py index 2651f359112..cf3d0a93805 100644 --- a/kyu_8/check_the_exam/check_exam.py +++ b/kyu_8/check_the_exam/check_exam.py @@ -35,7 +35,7 @@ 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 From ffff071cfec027379c483ac9cb8381e4594f845b Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:04:28 -0800 Subject: [PATCH 55/81] Update well_of_ideas_easy_version.py kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py:12 in public function `well`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c8a19a9490d..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 @@ -10,7 +10,7 @@ def well(x: List[str]) -> str: """ - 'well' function + 'well' function. :param x: List[str] :return: str From a6c59da57ad0f60a8e3d93e32e385445bcef6ba1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:06:32 -0800 Subject: [PATCH 56/81] Update evaluator.py kyu_8/greek_sort/evaluator.py:10 in public function `evaluator`: D401: First line should be in imperative mood (perhaps 'Evaluate', not 'evaluator') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index f32ba347cc9..e4bcc1e5f8e 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - 'evaluator' function. + Comparator for a list of phonetic words. :param result: int :param expected: str From 82c1c83d47375fdcfbda52ee1b88daa8bda2a186 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:09:10 -0800 Subject: [PATCH 57/81] Update evaluator.py --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index e4bcc1e5f8e..908e2b3e7ff 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - Comparator for a list of phonetic words. + Compare two arguments. :param result: int :param expected: str From 3f63da4e307bcbde9fee53f73eff09538dc24e42 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:22:01 -0800 Subject: [PATCH 58/81] Update test_third_angle_of_triangle.py --- kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py | 1 - 1 file changed, 1 deletion(-) 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 353637dacae..39f3e1622cd 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 @@ -59,7 +59,6 @@ def test_other_angle(self): 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 From f1d31ca43e92863ec6efd74a695a7d32f718c793 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:27:55 -0800 Subject: [PATCH 59/81] Update test_third_angle_of_triangle.py --- .../test_third_angle_of_triangle.py | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) 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 39f3e1622cd..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 @@ -9,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 @@ -29,7 +30,12 @@ class OtherAngleTestCase(unittest.TestCase): """Testing other_angle function.""" - def test_other_angle(self): + @parameterized.expand([ + (30, 60, 90), + (60, 60, 60), + (43, 78, 59), + (10, 20, 150)]) + def test_other_angle(self, a, b, expected): """ Testing other_angle function with various test data. @@ -47,29 +53,5 @@ def test_other_angle(self): "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) - - 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) self.assertEqual(other_angle(a, b), expected) From 73457ed871bbc9335b3d640571bdc0c8c3c646b8 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:36:40 -0800 Subject: [PATCH 60/81] pydocstyle for main --- .../workflows/lint_test_build_pipeline.yml | 3 + .github/workflows/pydocstyle.yml | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/pydocstyle.yml diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index 28eaad4cef4..f2cd7abf847 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -22,6 +22,9 @@ jobs: yamllint: name: YAML Lint uses: iKostanOrg/codewars/.github/workflows/yamllint.yml@master + pydocstyle: + name: PYDOCSTYLE Lint + uses: iKostanOrg/codewars/.github/workflows/pydocstyle.yml@master pytest: name: Unitest with pytest needs: diff --git a/.github/workflows/pydocstyle.yml b/.github/workflows/pydocstyle.yml new file mode 100644 index 00000000000..83134517527 --- /dev/null +++ b/.github/workflows/pydocstyle.yml @@ -0,0 +1,66 @@ +--- +name: pydocstyle + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'utils' + - 'none' + workflow_call: + +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 + # Pydocstyle testing (Guide) + # https://www.pydocstyle.org/en/stable/usage.html#cli-usage + - name: Doc style checking with pydocstyle for kyu_2 + run: | + pydocstyle --verbose --explain --count kyu_2 + - name: Doc style checking with pydocstyle for kyu_3 + run: | + pydocstyle --verbose --explain --count kyu_3 + - name: Doc style checking with pydocstyle for kyu_4 + run: | + pydocstyle --verbose --explain --count kyu_4 + - name: Doc style checking with pydocstyle for kyu_5 + run: | + pydocstyle --verbose --explain --count kyu_5 + - name: Doc style checking with pydocstyle for kyu_6 + run: | + pydocstyle --verbose --explain --count kyu_6 + - name: Doc style checking with pydocstyle for kyu_7 + run: | + pydocstyle --verbose --explain --count kyu_7 + - name: Doc style checking with pydocstyle for kyu_8 + run: | + pydocstyle --verbose --explain --count kyu_8 From 4e001d6e48d8eb9fed1ac50f18b4ef63c6055637 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:38:25 -0800 Subject: [PATCH 61/81] Update closest_elevator.py ./kyu_8/closest_elevator/closest_elevator.py:8:1: E302 expected 2 blank lines, found 1 def elevator(left: int, right: int, call: int) -> str: --- kyu_8/closest_elevator/closest_elevator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_8/closest_elevator/closest_elevator.py b/kyu_8/closest_elevator/closest_elevator.py index 3a04743db19..74c694ee278 100644 --- a/kyu_8/closest_elevator/closest_elevator.py +++ b/kyu_8/closest_elevator/closest_elevator.py @@ -5,6 +5,7 @@ GitHub: https://github.com/ikostan """ + def elevator(left: int, right: int, call: int) -> str: """ Return closest elevator number. From 86d4a41c9bee5baa3f68a8d3d3b85fb3106cc01a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:39:44 -0800 Subject: [PATCH 62/81] Update test_take.py ./kyu_8/enumerable_magic_25/test_take.py:65:27: E127 continuation line over-indented for visual indent n=n, ^ ./kyu_8/enumerable_magic_25/test_take.py:66:27: E127 continuation line over-indented for visual indent expected=expected, ^ ./kyu_8/enumerable_magic_25/test_take.py:67:27: E127 continuation line over-indented for visual indent result=actual_result) --- kyu_8/enumerable_magic_25/test_take.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kyu_8/enumerable_magic_25/test_take.py b/kyu_8/enumerable_magic_25/test_take.py index 97d7be1a043..7d94d7dee78 100644 --- a/kyu_8/enumerable_magic_25/test_take.py +++ b/kyu_8/enumerable_magic_25/test_take.py @@ -61,9 +61,9 @@ def test_take(self, arr, n, expected): f"expected output ({expected}) " f"vs actual result ({actual_result})"): - print_log(rr=arr, - n=n, - expected=expected, - result=actual_result) + print_log(arr=arr, + n=n, + expected=expected, + result=actual_result) self.assertEqual(expected, actual_result) From 47bab94c8e699dc8fc6ec8b1a3ab74a2fc8ec05a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:41:12 -0800 Subject: [PATCH 63/81] Update README.md Error: kyu_8/closest_elevator/README.md:21 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md --- kyu_8/closest_elevator/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/closest_elevator/README.md b/kyu_8/closest_elevator/README.md index 51e1fa33e81..51c872ea4ac 100644 --- a/kyu_8/closest_elevator/README.md +++ b/kyu_8/closest_elevator/README.md @@ -18,7 +18,7 @@ You can assume that the inputs will always be valid integers between 0-2. ## Examples -``` +```bash left right call result 0 1 0 "left" 0 1 1 "right" From 3b68c84f0c506299190700416b6e1b98e9853978 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:50:41 -0800 Subject: [PATCH 64/81] Update lint_test_build_pipeline.yml --- .github/workflows/lint_test_build_pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index f2cd7abf847..087bb2a7562 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -33,6 +33,7 @@ jobs: - markdown - mypy - yamllint + - pydocstyle uses: iKostanOrg/codewars/.github/workflows/pytest.yml@master codecov: name: Codecov GitHub Action From c8b9a8d1bffcc3c2d03f5d6ac3a82637f64eccb0 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:54:38 -0800 Subject: [PATCH 65/81] Update lint_test_build_pipeline.yml --- .github/workflows/lint_test_build_pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index 087bb2a7562..8208a76196f 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -23,7 +23,7 @@ jobs: name: YAML Lint uses: iKostanOrg/codewars/.github/workflows/yamllint.yml@master pydocstyle: - name: PYDOCSTYLE Lint + name: PyDocStyle Lint uses: iKostanOrg/codewars/.github/workflows/pydocstyle.yml@master pytest: name: Unitest with pytest From 2f84a83a83ffe52bc8679deb14b84dc154e63673 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:56:01 -0800 Subject: [PATCH 66/81] Update markdown_lint.yml --- .github/workflows/markdown_lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_lint.yml b/.github/workflows/markdown_lint.yml index 64a623ac2da..e857a509871 100644 --- a/.github/workflows/markdown_lint.yml +++ b/.github/workflows/markdown_lint.yml @@ -1,5 +1,5 @@ --- -name: 'Markdown Lint' +name: Markdown Lint on: # yamllint disable-line rule:truthy push: From 67146681851e9d11972fb5ee2a0dc086724e42d2 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:42:42 -0800 Subject: [PATCH 67/81] Update requirements.txt --- requirements.txt | Bin 2808 -> 2808 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644 GIT binary patch delta 14 Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM delta 14 Vcmew%`a^UB6APosW@eVJYyc?^1iJtL From c984b53130c64d354b0e60569f31b5f3011ddc48 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:06:13 -0800 Subject: [PATCH 68/81] Complete The Pattern #5 - Even Ladder --- kyu_7/coloured_triangles/test_triangle.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kyu_7/coloured_triangles/test_triangle.py b/kyu_7/coloured_triangles/test_triangle.py index 36dd38491bf..e947d6352f4 100644 --- a/kyu_7/coloured_triangles/test_triangle.py +++ b/kyu_7/coloured_triangles/test_triangle.py @@ -56,6 +56,16 @@ def test_triangle(self, string, expected): :return: """ + # pylint: disable-msg=R0801 + allure.dynamic.title("Basic test case for triangle func.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # pylint: enable-msg=R0801 with allure.step(f"Enter test string: {string} " f"and verify the output: {expected}"): result = triangle(string) From 710e43775338f50e794426ab1dc977a4c9c62130 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:36:47 -0800 Subject: [PATCH 69/81] Complete The Pattern #5 - Even Ladder. --- kyu_7/README.md | 72 ++++++++++--------- .../README.md | 38 ++++++++++ .../__init__.py | 1 + .../solution.py | 28 ++++++++ .../test_pattern.py | 67 +++++++++++++++++ 5 files changed, 171 insertions(+), 35 deletions(-) create mode 100644 kyu_7/complete_the_pattern_5_even_ladder/README.md create mode 100644 kyu_7/complete_the_pattern_5_even_ladder/__init__.py create mode 100644 kyu_7/complete_the_pattern_5_even_ladder/solution.py create mode 100644 kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py diff --git a/kyu_7/README.md b/kyu_7/README.md index 4635eace2cc..0a547bdaa9c 100644 --- a/kyu_7/README.md +++ b/kyu_7/README.md @@ -15,40 +15,42 @@ rank - the harder the kata the faster you advance. ### List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|:-------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------:| -| 1 | [Always perfect](https://www.codewars.com/kata/55f3facb78a9fd5b26000036) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/always_perfect) | -| 2 | [Beginner Series #3 Sum of Numbers](https://www.codewars.com/kata/55f2b110f61eb01779000053) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/beginner_series_sum_of_numbers) | -| 2 | [Coloured Triangles](https://www.codewars.com/kata/5a25ac6ac5e284cfbe000111) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/coloured_triangles) | -| 3 | [Disemvowel Trolls](https://www.codewars.com/kata/52fba66badcd10859f00097e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/disemvowel_trolls) | -| 4 | [Factorial](https://www.codewars.com/kata/54ff0d1f355cfd20e60001fc) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/factorial) | -| 5 | [Computer problem series #1](https://www.codewars.com/kata/5d49c93d089c6e000ff8428c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/fill_the_hard_disk_drive) | -| 6 | [Fun with lists: length](https://www.codewars.com/kata/581e476d5f59408553000a4b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/fun_with_lists_length) | -| 7 | [Jaden Casing Strings](https://www.codewars.com/kata/5390bac347d09b7da40006f6) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/jaden_casing_strings) | -| 8 | [Make Class](https://www.codewars.com/kata/5d774cfde98179002a7cb3c8) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/make_class) | -| 9 | [Maximum Multiple](https://www.codewars.com/kata/5aba780a6a176b029800041c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/maximum_multiple) | -| 10 | [Password validator](https://www.codewars.com/kata/56a921fa8c5167d8e7000053) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/password_validator) | -| 11 | [Powers of 3](https://www.codewars.com/kata/57be674b93687de78c0001d9) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/powers_of_3) | -| 12 | [Pull your words together, man!](https://www.codewars.com/kata/59ad7d2e07157af687000070) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/pull_your_words_together_man) | -| 13 | [The museum of incredible dull things](https://www.codewars.com/kata/563cf89eb4747c5fb100001b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/remove_the_minimum) | -| 14 | [Share price](https://www.codewars.com/kata/5603a4dd3d96ef798f000068) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/share_prices) | -| 15 | [Significant Figures Challenge](https://www.codewars.com/kata/5d9fe0ace0aad7001290acb7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/significant_figures) | -| 16 | [Simple Fun #152: Invite More Women](https://www.codewars.com/kata/58acfe4ae0201e1708000075) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/simple_fun_152) | -| 17 | [Sort Out The Men From Boys](https://www.codewars.com/kata/5af15a37de4c7f223e00012d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sort_out_the_men_from_boys) | -| 18 | [Substituting Variables Into Strings: Padded Numbers](https://www.codewars.com/kata/51c89385ee245d7ddf000001) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/substituting_variables_into_strings_padded_numbers) | -| 19 | [Sum of powers of 2](https://www.codewars.com/kata/5d9f95424a336600278a9632) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_powers_of_2) | -| 20 | [Sum of Triangular Numbers](https://www.codewars.com/kata/580878d5d27b84b64c000b51) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_triangular_numbers) | -| 21 | [Sum of two lowest positive integers](https://www.codewars.com/kata/558fc85d8fd1938afb000014) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_two_lowest_int) | -| 22 | [The First Non Repeated Character In A String](https://www.codewars.com/kata/570f6436b29c708a32000826) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/the_first_non_repeated_character_in_string) | -| 23 | [V A P O R C O D E](https://www.codewars.com/kata/5966eeb31b229e44eb00007a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/vaporcode) | -| 24 | [You're a square](https://www.codewars.com/kata/54c27a33fb7da0db0100040e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/you_are_square) | -| 25 | [Find the longest gap!](https://www.codewars.com/kata/55b86beb1417eab500000051) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/find_the_longest_gap) | -| 26 | [Simple Fun #74: Growing Plant](https://www.codewars.com/kata/58941fec8afa3618c9000184) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/growing_plant) | -| 27 | [Basic Math (Add or Subtract)](https://www.codewars.com/kata/5809b62808ad92e31b000031) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/basic_math_add_or_subtract) | -| 28 | [Sum of odd numbers](https://www.codewars.com/kata/55fd2d567d94ac3bc9000064) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_odd_numbers) | -| 29 | [Help Bob count letters and digits](https://www.codewars.com/kata/5738f5ea9545204cec000155) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/help_bob_count_letters_and_digits) | -| 30 | [Make Class](https://www.codewars.com/kata/5d774cfde98179002a7cb3c8) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/make_class) | -| 30 | [Easy Line](https://www.codewars.com/kata/56e7d40129035aed6c000632) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/easy_line) | -| 31 | [Valid Parentheses](https://www.codewars.com/kata/6411b91a5e71b915d237332d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/valid_parentheses) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------:| +| 1 | [Always perfect](https://www.codewars.com/kata/55f3facb78a9fd5b26000036) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/always_perfect) | +| 2 | [Beginner Series #3 Sum of Numbers](https://www.codewars.com/kata/55f2b110f61eb01779000053) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/beginner_series_sum_of_numbers) | +| 2 | [Coloured Triangles](https://www.codewars.com/kata/5a25ac6ac5e284cfbe000111) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/coloured_triangles) | +| 3 | [Disemvowel Trolls](https://www.codewars.com/kata/52fba66badcd10859f00097e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/disemvowel_trolls) | +| 4 | [Factorial](https://www.codewars.com/kata/54ff0d1f355cfd20e60001fc) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/factorial) | +| 5 | [Computer problem series #1](https://www.codewars.com/kata/5d49c93d089c6e000ff8428c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/fill_the_hard_disk_drive) | +| 6 | [Fun with lists: length](https://www.codewars.com/kata/581e476d5f59408553000a4b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/fun_with_lists_length) | +| 7 | [Jaden Casing Strings](https://www.codewars.com/kata/5390bac347d09b7da40006f6) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/jaden_casing_strings) | +| 8 | [Make Class](https://www.codewars.com/kata/5d774cfde98179002a7cb3c8) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/make_class) | +| 9 | [Maximum Multiple](https://www.codewars.com/kata/5aba780a6a176b029800041c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/maximum_multiple) | +| 10 | [Password validator](https://www.codewars.com/kata/56a921fa8c5167d8e7000053) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/password_validator) | +| 11 | [Powers of 3](https://www.codewars.com/kata/57be674b93687de78c0001d9) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/powers_of_3) | +| 12 | [Pull your words together, man!](https://www.codewars.com/kata/59ad7d2e07157af687000070) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/pull_your_words_together_man) | +| 13 | [The museum of incredible dull things](https://www.codewars.com/kata/563cf89eb4747c5fb100001b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/remove_the_minimum) | +| 14 | [Share price](https://www.codewars.com/kata/5603a4dd3d96ef798f000068) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/share_prices) | +| 15 | [Significant Figures Challenge](https://www.codewars.com/kata/5d9fe0ace0aad7001290acb7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/significant_figures) | +| 16 | [Simple Fun #152: Invite More Women](https://www.codewars.com/kata/58acfe4ae0201e1708000075) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/simple_fun_152) | +| 17 | [Sort Out The Men From Boys](https://www.codewars.com/kata/5af15a37de4c7f223e00012d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sort_out_the_men_from_boys) | +| 18 | [Substituting Variables Into Strings: Padded Numbers](https://www.codewars.com/kata/51c89385ee245d7ddf000001) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/substituting_variables_into_strings_padded_numbers) | +| 19 | [Sum of powers of 2](https://www.codewars.com/kata/5d9f95424a336600278a9632) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_powers_of_2) | +| 20 | [Sum of Triangular Numbers](https://www.codewars.com/kata/580878d5d27b84b64c000b51) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_triangular_numbers) | +| 21 | [Sum of two lowest positive integers](https://www.codewars.com/kata/558fc85d8fd1938afb000014) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_two_lowest_int) | +| 22 | [The First Non Repeated Character In A String](https://www.codewars.com/kata/570f6436b29c708a32000826) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/the_first_non_repeated_character_in_string) | +| 23 | [V A P O R C O D E](https://www.codewars.com/kata/5966eeb31b229e44eb00007a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/vaporcode) | +| 24 | [You're a square](https://www.codewars.com/kata/54c27a33fb7da0db0100040e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/you_are_square) | +| 25 | [Find the longest gap!](https://www.codewars.com/kata/55b86beb1417eab500000051) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/find_the_longest_gap) | +| 26 | [Simple Fun #74: Growing Plant](https://www.codewars.com/kata/58941fec8afa3618c9000184) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/growing_plant) | +| 27 | [Basic Math (Add or Subtract)](https://www.codewars.com/kata/5809b62808ad92e31b000031) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/basic_math_add_or_subtract) | +| 28 | [Sum of odd numbers](https://www.codewars.com/kata/55fd2d567d94ac3bc9000064) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/sum_of_odd_numbers) | +| 29 | [Help Bob count letters and digits](https://www.codewars.com/kata/5738f5ea9545204cec000155) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/help_bob_count_letters_and_digits) | +| 30 | [Make Class](https://www.codewars.com/kata/5d774cfde98179002a7cb3c8) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/make_class) | +| 31 | [Easy Line](https://www.codewars.com/kata/56e7d40129035aed6c000632) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/easy_line) | +| 32 | [Valid Parentheses](https://www.codewars.com/kata/6411b91a5e71b915d237332d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/valid_parentheses) | +| 33 | [Complete The Pattern #5 - Even Ladder](https://www.codewars.com/kata/55749101ae1cf7673800003e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_7/complete_the_pattern_5_even_ladder) | + [Source](https://www.codewars.com/about) \ No newline at end of file diff --git a/kyu_7/complete_the_pattern_5_even_ladder/README.md b/kyu_7/complete_the_pattern_5_even_ladder/README.md new file mode 100644 index 00000000000..367f7155fc7 --- /dev/null +++ b/kyu_7/complete_the_pattern_5_even_ladder/README.md @@ -0,0 +1,38 @@ +# Complete The Pattern #5 - Even Ladder + +## Description + +You have to write a function pattern which creates the following pattern +up to `n/2` number of lines. + +If `n <= 1` then it should return `""` (i.e. empty string). + +If any odd number is passed as argument then the pattern should last up to +the largest even number which is smaller than the passed odd number. + + +## Examples + +```bash +n = 8: + +22 +4444 +666666 +88888888 + +n = 5: + +22 +4444 +``` + +### Note + +There are no spaces in the pattern. + +### Hint + +Use `\n` in string to jump to next line. + +[Source](https://www.codewars.com/kata/55749101ae1cf7673800003e) \ No newline at end of file diff --git a/kyu_7/complete_the_pattern_5_even_ladder/__init__.py b/kyu_7/complete_the_pattern_5_even_ladder/__init__.py new file mode 100644 index 00000000000..8048083f2b2 --- /dev/null +++ b/kyu_7/complete_the_pattern_5_even_ladder/__init__.py @@ -0,0 +1 @@ +"""Complete The Pattern #5 - Even Ladder.""" diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py new file mode 100644 index 00000000000..ac3c29be7c2 --- /dev/null +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -0,0 +1,28 @@ +""" +Solution for -> Complete The Pattern #5 - Even Ladder. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +def pattern(n: int) -> str: + """ + 'pattern' function. + + Create the pattern up to n/2 number of lines. + :param n: + :return: + """ + # If n <= 1 then it should return "" (i.e. empty string). + if n < 2: + return '' + #If any odd number is passed as argument then the pattern + # should last up to the largest even number which is smaller + # than the passed odd number. + lines: list = [] + for i in range(2, n + 1, 2): + # Note: There are no spaces in the pattern. + line = (f'{i}' * i) + lines.append(line) + # Use \n in string to jump to next line. + return '\n'.join(lines) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py new file mode 100644 index 00000000000..ccf46073ca5 --- /dev/null +++ b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py @@ -0,0 +1,67 @@ +""" +Test for -> Complete The Pattern #5 - Even Ladder. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +# ASCII FUNDAMENTALS + +import unittest +import allure # pylint: disable=import-error +from parameterized import parameterized +from utils.log_func import print_log +from kyu_7.complete_the_pattern_5_even_ladder.solution import pattern + + +# pylint: disable-msg=R0801 +@allure.epic('7 kyu') +@allure.parent_suite('Beginner') +@allure.suite("Fundamentals") +@allure.sub_suite("Unit Tests") +@allure.feature("Lists") +@allure.story('Complete The Pattern #5 - Even Ladder') +@allure.tag('ASCII', + 'FUNDAMENTALS') +@allure.link( + url='https://www.codewars.com/kata/55749101ae1cf7673800003e', + name='Source/Kata') +# pylint: enable-msg=R0801 +class PatternTestCase(unittest.TestCase): + """Testing pattern function.""" + + @parameterized.expand([ + (2, "22"), + (1, ""), + (5, "22\n4444"), + (6, "22\n4444\n666666"), + (0, ""), + (-25, "")]) + def test_triangle(self, n, expected): + """ + Basic test case for pattern func. + + :return: + """ + # pylint: disable-msg=R0801 + allure.dynamic.title("Basic test case for pattern func.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

" + "If n <= 1 then it should return "" (i.e. empty string)." + "

" + "

" + "If any odd number is passed as argument then the pattern " + "should last up to the largest even number which is smaller " + "than the passed odd number." + "

") + # pylint: enable-msg=R0801 + with allure.step(f"Enter test number (n): {n} " + f"and verify the output: {expected}"): + result = pattern(n) + print_log(n=n, expected=expected, result=result) + self.assertEqual(expected, result, msg=expected) From d33aef18f329693657accfc776c2d8815e920021 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:39:27 -0800 Subject: [PATCH 70/81] Update solution.py --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index ac3c29be7c2..66d48f1b54e 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -16,13 +16,12 @@ def pattern(n: int) -> str: # If n <= 1 then it should return "" (i.e. empty string). if n < 2: return '' - #If any odd number is passed as argument then the pattern + # If any odd number is passed as argument then the pattern # should last up to the largest even number which is smaller # than the passed odd number. lines: list = [] for i in range(2, n + 1, 2): # Note: There are no spaces in the pattern. - line = (f'{i}' * i) - lines.append(line) + lines.append(f'{i}' * i) # Use \n in string to jump to next line. return '\n'.join(lines) From c5547335e8502066a87a1846d701cccb382bc86c Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:04:33 -0800 Subject: [PATCH 71/81] Create test_logical_calculator_error.py 90.41% (-0.39%) compared to 2f84a83 --- .../test_logical_calculator_error.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 kyu_8/logical_calculator/test_logical_calculator_error.py diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py new file mode 100644 index 00000000000..457640d57ba --- /dev/null +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -0,0 +1,62 @@ +""" +Test for -> Logical Calculator ValueError. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +# FUNDAMENTALS ARRAYS + +import unittest +import allure +import pytest +from utils.log_func import print_log +from kyu_8.logical_calculator.logical_calculator \ + import logical_calc + + +# pylint: disable=R0801 +@allure.epic('8 kyu') +@allure.parent_suite('Beginner') +@allure.suite("Data Structures") +@allure.sub_suite("Unit Tests") +@allure.feature("Lists") +@allure.story('Logical Calculator') +@allure.tag('FUNDAMENTALS', + 'ARRAYS' + "ValueError") +@allure.link( + url='https://www.codewars.com/kata/57096af70dad013aa200007b', + name='Source/Kata') +# pylint: enable=R0801 +class LogicalCalculatorValueErrorTestCase(unittest.TestCase): + """Testing ValueError.""" + + def test_logical_calc_value_error(self): + """ + Testing ValueError for logical_calc function. + :return: + """ + # pylint: disable=R0801 + allure.dynamic.title("Testing ValueError for logical_calc function.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

" + "Test Python Exception Handling Using 'pytest.raises'." + "

") + # pylint: enable=R0801 + with (allure.step("Pass an array with invalid operator.")): + arr: list = [] + op: str = 'RO' # invalid operator + operators: list = ['AND', 'OR', 'XOR'] + err = (f'ERROR: {op} is not a valid operator. ' + f'Please use one of the followings: {operators}') + with pytest.raises(ValueError) as calc_err: + logical_calc(arr, op) + self.assertEqual(str(calc_err.value), err) + From bee5ccc346208abdae8bda950405b84dbc3dd25d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:10:41 -0800 Subject: [PATCH 72/81] Update solution.py suggestion (code-quality): Convert for loop into list comprehension (list-comprehension) --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index 66d48f1b54e..cce9f20d504 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -19,9 +19,7 @@ def pattern(n: int) -> str: # If any odd number is passed as argument then the pattern # should last up to the largest even number which is smaller # than the passed odd number. - lines: list = [] - for i in range(2, n + 1, 2): - # Note: There are no spaces in the pattern. - lines.append(f'{i}' * i) + # Note: There are no spaces in the pattern.lines.append() # Use \n in string to jump to next line. + lines: list = [(f'{i}' * i) for i in range(2, n + 1, 2)] return '\n'.join(lines) From 372d14fa5605efcfec7b65a66236b17ccf913cd3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:16:40 -0800 Subject: [PATCH 73/81] Update test_pattern.py --- .../test_pattern.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py index ccf46073ca5..27d667468c3 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py @@ -37,7 +37,7 @@ class PatternTestCase(unittest.TestCase): (6, "22\n4444\n666666"), (0, ""), (-25, "")]) - def test_triangle(self, n, expected): + def test_pattern(self, n, expected): """ Basic test case for pattern func. @@ -65,3 +65,30 @@ def test_triangle(self, n, expected): result = pattern(n) print_log(n=n, expected=expected, result=result) self.assertEqual(expected, result, msg=expected) + + @parameterized.expand([ + (8, "22\n4444\n666666\n88888888")]) + def test_pattern_has_no_spaces(self, n, expected): + """ + Output should not have any spaces.. + + :return: + """ + # pylint: disable-msg=R0801 + allure.dynamic.title("Test no spaces in output.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

" + "There are no spaces in the pattern." + "

") + # pylint: enable-msg=R0801 + with allure.step(f"Enter test number (n): {n} " + "and verify the output has no spaces."): + result = pattern(n) + print_log(n=n, expected=expected, result=result) + self.assertEqual(result, expected) + self.assertEqual(result.count(' '), 0) From afa284ce040b1e9fe7720706e7b3d5a767cc4c2f Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:25:00 -0800 Subject: [PATCH 74/81] Update test_logical_calculator_error.py Trailing newlines kyu_8/logical_calculator/ test_logical_calculator_error.py 62 self.assertEqual(str(calc_err.value), err) --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 457640d57ba..56b92e06b2d 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -59,4 +59,3 @@ def test_logical_calc_value_error(self): with pytest.raises(ValueError) as calc_err: logical_calc(arr, op) self.assertEqual(str(calc_err.value), err) - From 947261ec4b2b0a30a4bd1bf49ea4f5672b0152cc Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:25:55 -0800 Subject: [PATCH 75/81] Update test_logical_calculator_error.py Unnecessary parens after 'with' keyword kyu_8/logical_calculator/ test_logical_calculator_error.py 51 "

") 52 # pylint: enable=R0801 53 with (allure.step("Pass an array with invalid operator.")): 54 arr: list = [] 55 op: str = 'RO' # invalid operator --- kyu_8/logical_calculator/test_logical_calculator_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 56b92e06b2d..c35118a1c4c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -50,7 +50,7 @@ def test_logical_calc_value_error(self): "Test Python Exception Handling Using 'pytest.raises'." "

") # pylint: enable=R0801 - with (allure.step("Pass an array with invalid operator.")): + with allure.step("Pass an array with invalid operator."): arr: list = [] op: str = 'RO' # invalid operator operators: list = ['AND', 'OR', 'XOR'] From 10e9323525d38f78669b8d5a4f5fcfd2a5926a62 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:26:43 -0800 Subject: [PATCH 76/81] Update test_logical_calculator_error.py Unused print_log imported from utils.log_func kyu_8/logical_calculator/ test_logical_calculator_error.py 13 from utils.log_func import print_log --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index c35118a1c4c..0378bc8575c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -10,7 +10,6 @@ import unittest import allure import pytest -from utils.log_func import print_log from kyu_8.logical_calculator.logical_calculator \ import logical_calc From cbdfe06a8366efe9e8387af537cd2948b6e5c380 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:44:55 -0800 Subject: [PATCH 77/81] Update solution.py ./kyu_7/complete_the_pattern_5_even_ladder/solution.py:8:1: E302 expected 2 blank lines, found 1 def pattern(n: int) -> str: ^ 1 E302 expected 2 blank lines, found 1 --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index cce9f20d504..0cf706672e6 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -5,6 +5,7 @@ GitHub: https://github.com/ikostan """ + def pattern(n: int) -> str: """ 'pattern' function. From 8af04dfa2449bb6c14539d7efe7c6c7a7edab142 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:45:56 -0800 Subject: [PATCH 78/81] Update test_logical_calculator_error.py kyu_8/logical_calculator/test_logical_calculator_error.py:35 in public method `test_logical_calc_value_error`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 0378bc8575c..98bafed968c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -34,6 +34,7 @@ class LogicalCalculatorValueErrorTestCase(unittest.TestCase): def test_logical_calc_value_error(self): """ Testing ValueError for logical_calc function. + :return: """ # pylint: disable=R0801 From cb8aece05846248ba048c4b0caf1d11fd076364d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:48:16 -0800 Subject: [PATCH 79/81] Update test_logical_calculator_error.py --- kyu_8/logical_calculator/test_logical_calculator_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 98bafed968c..7564d32e74c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -34,7 +34,7 @@ class LogicalCalculatorValueErrorTestCase(unittest.TestCase): def test_logical_calc_value_error(self): """ Testing ValueError for logical_calc function. - + :return: """ # pylint: disable=R0801 From e1efd56e214fb3ad44d9e5f03942af16f105c194 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:57:31 -0800 Subject: [PATCH 80/81] Create flake8_kyu8.yml --- .github/workflows/flake8_kyu8.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/flake8_kyu8.yml diff --git a/.github/workflows/flake8_kyu8.yml b/.github/workflows/flake8_kyu8.yml new file mode 100644 index 00000000000..1685c7f2aee --- /dev/null +++ b/.github/workflows/flake8_kyu8.yml @@ -0,0 +1,47 @@ +--- +name: Flake8 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 flake8 + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Lint with flake8 + # yamllint disable rule:line-length + # stop the build if there are Python syntax errors or undefined names + # exit-zero treats all errors as warnings. + # The GitHub editor is 127 chars wide + run: | + flake8 --count --select=E9,F63,F7,F82 --doctests --show-source --statistics ./kyu_8 + flake8 --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics ./kyu_8 + # yamllint enable rule:line-length From 46af6a870b786636594fd875605d0082592960ed Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 05:09:21 -0800 Subject: [PATCH 81/81] Create flake8_kyu7.yml --- .github/workflows/flake8_kyu7.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/flake8_kyu7.yml diff --git a/.github/workflows/flake8_kyu7.yml b/.github/workflows/flake8_kyu7.yml new file mode 100644 index 00000000000..f6c3ad57586 --- /dev/null +++ b/.github/workflows/flake8_kyu7.yml @@ -0,0 +1,47 @@ +--- +name: Flake8 for kyu7 + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'kyu7' + +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 flake8 + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Lint with flake8 + # yamllint disable rule:line-length + # stop the build if there are Python syntax errors or undefined names + # exit-zero treats all errors as warnings. + # The GitHub editor is 127 chars wide + run: | + flake8 --count --select=E9,F63,F7,F82 --doctests --show-source --statistics ./kyu_7 + flake8 --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics ./kyu_7 + # yamllint enable rule:line-length