diff --git a/.github/workflows/pydocstyle_kyu4.yml b/.github/workflows/pydocstyle_kyu4.yml new file mode 100644 index 00000000000..fb5fab4f43d --- /dev/null +++ b/.github/workflows/pydocstyle_kyu4.yml @@ -0,0 +1,46 @@ +--- +name: pydocstyle for kyu4 + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'kyu4' + +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_4 diff --git a/kyu_4/__init__.py b/kyu_4/__init__.py index e69de29bb2d..f4a82f04020 100644 --- a/kyu_4/__init__.py +++ b/kyu_4/__init__.py @@ -0,0 +1 @@ +"""Codewars kyu_4 package.""" diff --git a/kyu_4/human_readable_duration_format/__init__.py b/kyu_4/human_readable_duration_format/__init__.py index e69de29bb2d..056c0879651 100644 --- a/kyu_4/human_readable_duration_format/__init__.py +++ b/kyu_4/human_readable_duration_format/__init__.py @@ -0,0 +1 @@ +"""Human readable duration format package.""" diff --git a/kyu_4/human_readable_duration_format/format_duration.py b/kyu_4/human_readable_duration_format/format_duration.py index 3bf8955a6a3..c1c41e583de 100644 --- a/kyu_4/human_readable_duration_format/format_duration.py +++ b/kyu_4/human_readable_duration_format/format_duration.py @@ -1,4 +1,6 @@ """ +Format duration. + A function which formats a duration, given as a number of seconds, in a human-friendly way. Created by Egor Kostan. @@ -8,37 +10,13 @@ def format_duration(seconds: int) -> str: """ + format_duration function. + A function which formats a duration, given as a number of seconds, in a human-friendly way. - - The resulting expression is made of components like 4 seconds, - 1 year, etc. In general, a positive integer and one of the - valid units of time, separated by a space. The unit of time - is used in plural if the integer is greater than 1. - - The components are separated by a comma and a space (", "). - Except the last component, which is separated by " and ", just - like it would be written in English. - - A more significant units of time will occur before than a least - significant one. Therefore, 1 second and 1 year is not correct, - but 1 year and 1 second is. - - Different components have different unit of times. So there is - not repeated units like in 5 seconds and 1 second. - - A component will not appear at all if its value happens to be zero. - Hence, 1 minute and 0 seconds is not valid, but it should be just 1 minute. - - A unit of time must be used "as much as possible". It means that the - function should not return 61 seconds, but 1 minute and 1 second instead. - Formally, the duration specified by of a component must not be greater than - any valid more significant unit of time. - :param seconds: int :return: str """ - if seconds == 0: return 'now' @@ -67,34 +45,36 @@ def format_duration(seconds: int) -> str: return result -def format_days(days: int, day: str, result: str) -> str: +def format_days(days: int, + day: str, + result: str) -> str: """ - Format days for the final string - :param days: - :param day: - :param result: - :return: + Format days for the final string. + + :param days: int + :param day: str + :param result: str + :return: str """ - if days > 0 and result != '': - result += f', {day}' - elif days > 0: - result += f'{day}' + if days > 0: + result += f', {day}' if result else f'{day}' return result -def format_hours(hours: int, hour: str, result: str) -> str: +def format_hours(hours: int, + hour: str, + result: str) -> str: """ - Format hours for the final string - :param hours: - :param hour: - :param result: - :return: + Format hours for the final string. + + :param hours: int + :param hour: str + :param result: str + :return: str """ - if hours > 0 and result != '': - result += f', {hour}' - elif hours > 0: - result += f'{hour}' + if hours > 0: + result += f', {hour}' if result else f'{hour}' return result @@ -104,12 +84,13 @@ def format_minutes(minutes: int, minute: str, result: str) -> str: """ - Format minutes for the final string - :param minutes: - :param seconds: - :param minute: - :param result: - :return: + Format minutes for the final string. + + :param minutes: int + :param seconds: int + :param minute: str + :param result: str + :return: str """ if minutes > 0 and result != '' and seconds == 0: result += f' and {minute}' @@ -123,26 +104,27 @@ def format_minutes(minutes: int, def format_seconds(seconds: int, second: str, result: str) -> str: """ - Format seconds for the final string - :param seconds: - :param second: - :param result: - :return: + Format seconds for the final string. + + :param seconds: int + :param second: str + :param result: str + :return: str """ - if seconds > 0 and result != '': - result += f' and {second}' - elif seconds > 0: - result += f'{second}' + if seconds > 0: + result += f' and {second}' if result else f'{second}' return result -def get_string(number: int, string: str) -> str: +def get_string(number: int, + string: str) -> str: """ - Concatenate string result - :param number: - :param string: - :return: + Concatenate string result. + + :param number: int + :param string: str + :return: str """ result: str = '' if number == 1: @@ -155,59 +137,52 @@ def get_string(number: int, string: str) -> str: def calc_seconds(seconds: int) -> int: """ - Calculate seconds - :param seconds: - :return: - """ - if seconds < 60: - return seconds + Calculate seconds. - return seconds % 60 + :param seconds: int + :return: int + """ + return seconds if seconds < 60 else seconds % 60 def calc_minutes(seconds: int) -> int: """ - calculate minutes - :param seconds: - :return: + Calculate minutes. + + :param seconds: int + :return: int """ minutes = seconds // 60 - if minutes < 60: - return minutes - - return minutes % 60 + return minutes if minutes < 60 else minutes % 60 def calc_hours(seconds: int) -> int: """ - Calculate hours - :param seconds: - :return: + Calculate hours. + + :param seconds: int + :return: int """ hours = seconds // (60 * 60) - if hours < 24: - return hours - - return hours % 24 + return hours if hours < 24 else hours % 24 def calc_days(seconds: int) -> int: """ - Calculate days - :param seconds: - :return: + Calculate days. + + :param seconds: int + :return: int """ days = seconds // (60 * 60 * 24) - if days < 365: - return days - - return days % 365 + return days if days < 365 else days % 365 def calc_years(seconds: int) -> int: """ - Calculate years - :param seconds: - :return: + Calculate years. + + :param seconds: int + :return: int """ return seconds // (60 * 60 * 24 * 365) diff --git a/kyu_4/human_readable_duration_format/test_format_duration.py b/kyu_4/human_readable_duration_format/test_format_duration.py index 0f498dc6ba2..6580a672242 100644 --- a/kyu_4/human_readable_duration_format/test_format_duration.py +++ b/kyu_4/human_readable_duration_format/test_format_duration.py @@ -1,5 +1,6 @@ """ -Test for 'Human readable duration format' +Test for 'Human readable duration format'. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,12 +30,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class FormatDurationTestCase(unittest.TestCase): - """ - Testing format_duration - """ + """Testing format_duration.""" def test_format_duration(self): """ + Test format_duration function. + Test a function which formats a duration, given as a number of seconds, in a human-friendly way. diff --git a/kyu_4/most_frequently_used_words/__init__.py b/kyu_4/most_frequently_used_words/__init__.py index e69de29bb2d..c288a6188db 100644 --- a/kyu_4/most_frequently_used_words/__init__.py +++ b/kyu_4/most_frequently_used_words/__init__.py @@ -0,0 +1 @@ +"""Most frequently used words in a text package.""" diff --git a/kyu_4/most_frequently_used_words/solution.py b/kyu_4/most_frequently_used_words/solution.py index 89813390c35..3557d1b8bd8 100644 --- a/kyu_4/most_frequently_used_words/solution.py +++ b/kyu_4/most_frequently_used_words/solution.py @@ -1,5 +1,6 @@ """ -Most frequently used words in a text +Most frequently used words in a text. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def top_3_words(text: str) -> list: """ + Top 3 words function. + Given a string of text (possibly with punctuation and line-breaks), returns an array of the top-3 most occurring words, in descending order of the number of occurrences. diff --git a/kyu_4/most_frequently_used_words/test_top_3_words.py b/kyu_4/most_frequently_used_words/test_top_3_words.py index 3e4c70af713..54e0dd1133a 100644 --- a/kyu_4/most_frequently_used_words/test_top_3_words.py +++ b/kyu_4/most_frequently_used_words/test_top_3_words.py @@ -1,5 +1,6 @@ """ -Test for 'Most frequently used words in a text' +Test for 'Most frequently used words in a text'. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -28,13 +29,13 @@ url='https://www.codewars.com/kata/51e056fe544cf36c410000fb', name='Source/Kata') class Top3WordsTestCase(unittest.TestCase): - """ - Testing top_3_words - """ + """Testing top_3_words.""" def test_top_3_words(self): """ - Test top_3_words function + Test top_3_words function with various test data. + + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing top_3_words function") diff --git a/kyu_4/next_bigger_number_with_the_same_digits/__init__.py b/kyu_4/next_bigger_number_with_the_same_digits/__init__.py index e69de29bb2d..30dc3d22713 100644 --- a/kyu_4/next_bigger_number_with_the_same_digits/__init__.py +++ b/kyu_4/next_bigger_number_with_the_same_digits/__init__.py @@ -0,0 +1 @@ +"""Next bigger number with the same digits package.""" diff --git a/kyu_4/next_bigger_number_with_the_same_digits/next_bigger.py b/kyu_4/next_bigger_number_with_the_same_digits/next_bigger.py index 889ff900f9b..1dda31b556f 100644 --- a/kyu_4/next_bigger_number_with_the_same_digits/next_bigger.py +++ b/kyu_4/next_bigger_number_with_the_same_digits/next_bigger.py @@ -1,5 +1,6 @@ """ -Solution for -> Next bigger number with the same digits +Solution for -> Next bigger number with the same digits. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,10 +8,14 @@ def next_bigger(n: int) -> int: """ + Next bigger function. + A function that takes a positive integer number and returns the next bigger number formed by the same digits. - If no bigger number can be composed using those digits, return -1 + If no bigger number can be composed using those digits, return -1. + :param n: + :return: """ # 1. Starting from last digit of given number, find the first digit # which breaks the sorted ordering. Let the index of this found @@ -32,6 +37,8 @@ def next_bigger(n: int) -> int: def digit_that_breaks_ordering_index(digits: list) -> int: """ + Find a digit that breaks ordering index. + Starting from last digit of given number, find the first digit which breaks the sorted ordering. Let the index of this found digit be 'i' and the digit be number[i]. @@ -48,6 +55,8 @@ def digit_that_breaks_ordering_index(digits: list) -> int: def next_greater_digit_index(digits: list, i: int) -> int: """ + Find next greater digit index. + Find the next greater digit in the right portion of number[i] - that is from digit at index i+1 to last digit. Let that digit be number[j] at index 'j'. @@ -62,11 +71,8 @@ def next_greater_digit_index(digits: list, i: int) -> int: return i for index, digit in enumerate(digits[i:]): - if digits[i - 1] < digit: - if current == '': - current = digit - j = i + index - elif current > digit: - current = digit - j = i + index + if digits[i - 1] < digit and (current == '' or current > digit): + current = digit + j = i + index + return j diff --git a/kyu_4/next_bigger_number_with_the_same_digits/test_next_bigger.py b/kyu_4/next_bigger_number_with_the_same_digits/test_next_bigger.py index 924c6be31c5..8f5e497334c 100644 --- a/kyu_4/next_bigger_number_with_the_same_digits/test_next_bigger.py +++ b/kyu_4/next_bigger_number_with_the_same_digits/test_next_bigger.py @@ -1,5 +1,6 @@ """ -Test for -> Next bigger number with the same digits +Test for -> Next bigger number with the same digits. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,12 +30,11 @@ name='Source/Kata') # pylint: enable-msg=R0801 class NextBiggerTestCase(unittest.TestCase): - """ - Testing next_bigger function - """ + """Testing next_bigger function.""" + def test_next_bigger(self): """ - Testing next_bigger function + Testing next_bigger function. You have to test a function that takes a positive integer number and returns the next bigger number formed by the same digits: @@ -43,7 +43,8 @@ def test_next_bigger(self): 513 ==> 531 2017 ==> 2071 - If no bigger number can be composed using those digits, return -1 + If no bigger number can be composed using those digits, return -1. + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing next_bigger function") diff --git a/kyu_4/next_smaller_number_with_the_same_digits/__init__.py b/kyu_4/next_smaller_number_with_the_same_digits/__init__.py index e69de29bb2d..da3bbbb87c5 100644 --- a/kyu_4/next_smaller_number_with_the_same_digits/__init__.py +++ b/kyu_4/next_smaller_number_with_the_same_digits/__init__.py @@ -0,0 +1 @@ +"""Next smaller number with the same digits package.""" diff --git a/kyu_4/next_smaller_number_with_the_same_digits/next_smaller.py b/kyu_4/next_smaller_number_with_the_same_digits/next_smaller.py index a0dfe8eb090..493628defdc 100644 --- a/kyu_4/next_smaller_number_with_the_same_digits/next_smaller.py +++ b/kyu_4/next_smaller_number_with_the_same_digits/next_smaller.py @@ -1,5 +1,6 @@ """ -Solution for -> Next smaller number with the same digits +Solution for -> Next smaller number with the same digits. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,10 +8,13 @@ def next_smaller(n: int) -> int: """ + next_smaller function. + A function that takes a positive integer and returns the next smaller positive integer containing the same digits. - If no smaller number can be composed using those digits, return -1 + :param n: int + :return: int """ # 1 # Starting from the right, find the index of the first digit that @@ -41,7 +45,8 @@ def next_smaller(n: int) -> int: def find_x(n: int) -> int: """ - Find x + Find x. + :param n: int :return: int """ @@ -54,7 +59,8 @@ def find_x(n: int) -> int: def find_y(n: int, x_i: int) -> int: """ - Find y + Find y. + :param n: int :param x_i: int :return: int @@ -75,4 +81,4 @@ def find_y(n: int, x_i: int) -> int: if comparable_x['y'] < y: comparable_x['y'] = y comparable_x['index'] = index + x_i + 1 - return comparable_x['index'] if comparable_x['index'] else -1 + return comparable_x['index'] or -1 diff --git a/kyu_4/next_smaller_number_with_the_same_digits/test_next_smaller.py b/kyu_4/next_smaller_number_with_the_same_digits/test_next_smaller.py index 0e1ad4b4264..2bb5262c59e 100644 --- a/kyu_4/next_smaller_number_with_the_same_digits/test_next_smaller.py +++ b/kyu_4/next_smaller_number_with_the_same_digits/test_next_smaller.py @@ -1,5 +1,6 @@ """ -Test for -> Next smaller number with the same digits +Test for -> Next smaller number with the same digits. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,13 +30,11 @@ name='Source/Kata') # pylint: enable-msg=R0801 class NextSmallerTestCase(unittest.TestCase): - """ - Testing next_smaller function - """ + """Testing next_smaller function.""" def test_next_smaller(self): """ - Testing next_smaller function + Testing next_smaller function. You have to test a function that takes a positive integer number and returns the next smaller number formed by the same digits: @@ -45,6 +44,7 @@ def test_next_smaller(self): 2071 ==> 2017 If no smaller number can be composed using those digits, return -1 + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing next_smaller function") diff --git a/kyu_4/permutations/__init__.py b/kyu_4/permutations/__init__.py index e69de29bb2d..942250b3c8e 100644 --- a/kyu_4/permutations/__init__.py +++ b/kyu_4/permutations/__init__.py @@ -0,0 +1 @@ +"""Permutations package.""" diff --git a/kyu_4/permutations/permutations.py b/kyu_4/permutations/permutations.py index 68cbdcf0c72..aab6185389c 100644 --- a/kyu_4/permutations/permutations.py +++ b/kyu_4/permutations/permutations.py @@ -1,5 +1,6 @@ """ -Solution for -. Permutations +Solution for -. Permutations. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,10 +8,14 @@ def permutations(string: str) -> list: """ + Permutation function. + creates all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders. + :param string: str + :return: list """ for strg in string: print(strg) diff --git a/kyu_4/permutations/test_permutations.py b/kyu_4/permutations/test_permutations.py index 04a4ffaecd6..b1ca433f5d4 100644 --- a/kyu_4/permutations/test_permutations.py +++ b/kyu_4/permutations/test_permutations.py @@ -1,5 +1,6 @@ """ -Solution for -. Permutations +Solution for -. Permutations. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -28,19 +29,18 @@ @pytest.mark.skip(reason="The solution is not ready") # pylint: enable-msg=R0801 class PermutationsTestCase(unittest.TestCase): - """ - Testing permutations function - """ + """Testing permutations function.""" def test_permutations(self): """ - Testing permutations function + Testing permutations function. Test that permutations function creates all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders. + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing permutations function") diff --git a/kyu_4/range_extraction/__init__.py b/kyu_4/range_extraction/__init__.py index e69de29bb2d..732db55fa77 100644 --- a/kyu_4/range_extraction/__init__.py +++ b/kyu_4/range_extraction/__init__.py @@ -0,0 +1 @@ +"""Range Extraction package.""" diff --git a/kyu_4/range_extraction/solution.py b/kyu_4/range_extraction/solution.py index 6fc40883d8e..b39d66d20b0 100644 --- a/kyu_4/range_extraction/solution.py +++ b/kyu_4/range_extraction/solution.py @@ -1,5 +1,6 @@ """ -Solution for -> Range Extraction +Solution for -> Range Extraction. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,10 +8,12 @@ def solution(args: list) -> str: """ + Solution for Range Extraction problem. + Tt takes a list of integers in increasing order and returns a correctly formatted string in the range format. - :param args: - :return: + :param args: list + :return: str """ current: list = [args[0], args[0], False] result: str = '' @@ -35,30 +38,34 @@ def solution(args: list) -> str: return result -def case_3(a: int, current: list, result: str) -> str: +def case_3(a: int, + current: list, + result: str) -> str: """ - Case #3 - :param a: - :param current: - :param result: - :return: + Case #3. + + :param a: int + :param current: list + :param result: str + :return: str """ if current[1] + 1 == a: current[1] = a result += str(current[0]) if abs(current[1] - current[0]) >= 2: - result += '-' + str(current[1]) + result += f'-{str(current[1])}' elif current[0] != current[1]: - result += ',' + str(current[1]) + result += f',{str(current[1])}' return result def case_2(**kwargs) -> str: """ - Case #2 - :return: + Case #2. + + :return: str """ a: int = kwargs['a'] i: int = kwargs['i'] @@ -72,11 +79,11 @@ def case_2(**kwargs) -> str: current[2] = True if abs(current[1] - current[0]) >= 2 and i != 1: - result += str(current[0]) + '-' + str(current[1]) + ',' + result += f'{str(current[0])}-{str(current[1])},' else: - result += str(current[0]) + ',' + result += f'{str(current[0])},' if current[0] != current[1]: - result += str(current[1]) + ',' + result += f'{str(current[1])},' current[0] = a current[1] = a diff --git a/kyu_4/range_extraction/test_solution.py b/kyu_4/range_extraction/test_solution.py index e7ee7fc8465..1827b11888c 100644 --- a/kyu_4/range_extraction/test_solution.py +++ b/kyu_4/range_extraction/test_solution.py @@ -1,5 +1,6 @@ """ -Test for -> Range Extraction +Test for -> Range Extraction. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,13 +28,13 @@ @allure.link(url='https://www.codewars.com/kata/51ba717bb08c1cd60f00002f', name='Source/Kata') class SolutionTestCase(unittest.TestCase): - """ - Testing solution for Range Extraction problem - """ + """Testing solution for Range Extraction problem.""" def test_solution(self): """ - Testing solution function + Testing solution function. + + :return: """ allure.dynamic.title("Testing solution function") allure.dynamic.severity(allure.severity_level.NORMAL) diff --git a/kyu_4/snail/__init__.py b/kyu_4/snail/__init__.py index e69de29bb2d..6ececdca848 100644 --- a/kyu_4/snail/__init__.py +++ b/kyu_4/snail/__init__.py @@ -0,0 +1 @@ +"""Snail Sort package.""" diff --git a/kyu_4/snail/snail_sort.py b/kyu_4/snail/snail_sort.py index 34f614c1144..9c8c0f73125 100644 --- a/kyu_4/snail/snail_sort.py +++ b/kyu_4/snail/snail_sort.py @@ -1,5 +1,5 @@ """ -Solution for -> Snail +Solution for -> Snail. Returns the array elements arranged from outermost elements to the middle element, traveling clockwise. @@ -11,6 +11,8 @@ def snail(snail_map: list) -> list: """ + Snail function. + Returns the array elements arranged from outermost elements to the middle element, traveling clockwise. diff --git a/kyu_4/snail/test_snail.py b/kyu_4/snail/test_snail.py index 4e92c26f8b3..ef6002302f3 100644 --- a/kyu_4/snail/test_snail.py +++ b/kyu_4/snail/test_snail.py @@ -1,5 +1,5 @@ """ -Test for -> Snail +Test for -> Snail. Returns the array elements arranged from outermost elements to the middle element, traveling clockwise. @@ -28,17 +28,16 @@ @allure.link(url='https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1', name='Source/Kata') class SnailTestCase(unittest.TestCase): - """ - Testing snail function - """ + """Testing snail function.""" def test_snail(self): """ - Testing 'snail' function + Testing 'snail' function. Given an n x n array, 'snail' function should return the array elements arranged from outermost elements to the middle element, traveling clockwise. + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing 'snail' function") diff --git a/kyu_4/strings_mix/README.md b/kyu_4/strings_mix/README.md index c09c168468d..0904770cf61 100644 --- a/kyu_4/strings_mix/README.md +++ b/kyu_4/strings_mix/README.md @@ -1,8 +1,8 @@ # Strings Mix -Given two strings `s1` and `s2`, we want to visualize how different the +****Given two strings `s1` and `s2`, we want to visualize how different the two strings are. We will only take into account the lowercase letters -(a to z). First let us count the frequency of each lowercase letters in +(a to z). Fir****st let us count the frequency of each lowercase letters in `s1` and `s2`. ```text diff --git a/kyu_4/strings_mix/__init__.py b/kyu_4/strings_mix/__init__.py index e69de29bb2d..19cbec43a11 100644 --- a/kyu_4/strings_mix/__init__.py +++ b/kyu_4/strings_mix/__init__.py @@ -0,0 +1 @@ +"""Strings Mix package.""" diff --git a/kyu_4/strings_mix/solution.py b/kyu_4/strings_mix/solution.py index a73966a0bfa..589f0eb6432 100644 --- a/kyu_4/strings_mix/solution.py +++ b/kyu_4/strings_mix/solution.py @@ -1,5 +1,6 @@ """ -Solution for -> Strings Mix +Solution for -> Strings Mix. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -11,6 +12,8 @@ def mix(s1: str, s2: str) -> str: """ + Mix function. + Given two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account the lowercase letters (a to z). @@ -48,6 +51,8 @@ def mix(s1: str, s2: str) -> str: def sort_results(results: list) -> list: """ + Sorting results function. + The results will be in decreasing order of their length and when they have the same length sorted in ascending lexicographic order (letters and digits - more precisely @@ -76,7 +81,8 @@ def sort_results(results: list) -> list: def get_counters(s: str) -> dict: """ - Get counters + Get counters. + :param s: str :return: dict """ diff --git a/kyu_4/strings_mix/test_mix.py b/kyu_4/strings_mix/test_mix.py index dec95adf8cd..5a441503863 100644 --- a/kyu_4/strings_mix/test_mix.py +++ b/kyu_4/strings_mix/test_mix.py @@ -1,5 +1,6 @@ """ -Test for -> Strings Mix +Test for -> Strings Mix. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,12 +25,11 @@ url='https://www.codewars.com/kata/5629db57620258aa9d000014', name='Source/Kata') class MixTestCase(unittest.TestCase): - """ - Testing solution for Strings Mix problem - """ + """Testing solution for Strings Mix problem.""" + def test_smix(self): """ - Testing 'mix' function + Testing 'mix' function. Given two strings s1 and s2, the 'mix' function should visualize how different the two strings are. diff --git a/kyu_4/strip_comments/__init__.py b/kyu_4/strip_comments/__init__.py index e69de29bb2d..62779246461 100644 --- a/kyu_4/strip_comments/__init__.py +++ b/kyu_4/strip_comments/__init__.py @@ -0,0 +1 @@ +"""Strip Comments package.""" diff --git a/kyu_4/strip_comments/solution.py b/kyu_4/strip_comments/solution.py index 6a3b065b3f5..7d7fac4512a 100644 --- a/kyu_4/strip_comments/solution.py +++ b/kyu_4/strip_comments/solution.py @@ -1,5 +1,6 @@ """ -Solution for -> Strip Comments +Solution for -> Strip Comments. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def solution(string: str, markers: list) -> str: """ + Strip comments solution. + The solution strips all text that follows any of a set of comment markers passed in. Any whitespace at the end of the line will be stripped out as well. diff --git a/kyu_4/strip_comments/test_solution.py b/kyu_4/strip_comments/test_solution.py index 68e78a365c7..20f5ab69343 100644 --- a/kyu_4/strip_comments/test_solution.py +++ b/kyu_4/strip_comments/test_solution.py @@ -1,5 +1,6 @@ """ -Test for -> Strip Comments +Test for -> Strip Comments. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -23,17 +24,16 @@ @allure.link(url='https://www.codewars.com/kata/51c8e37cee245da6b40000bd', name='Source/Kata') class SolutionTestCase(unittest.TestCase): - """ - Testing solution for Strip Comments problem - """ + """Testing solution for Strip Comments problem.""" def test_solution(self): """ - Testing 'solution' function + Testing 'solution' function. The solution should strips all text that follows any of a set of comment markers passed in. Any whitespace at the end of the line should also be stripped out. + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing 'solution' function") diff --git a/kyu_4/sudoku_solution_validator/__init__.py b/kyu_4/sudoku_solution_validator/__init__.py index e69de29bb2d..c5bdd87d16e 100644 --- a/kyu_4/sudoku_solution_validator/__init__.py +++ b/kyu_4/sudoku_solution_validator/__init__.py @@ -0,0 +1 @@ +"""Sudoku Solution Validator package.""" diff --git a/kyu_4/sudoku_solution_validator/test_valid_solution.py b/kyu_4/sudoku_solution_validator/test_valid_solution.py index a0c08843d60..65e27d6b58b 100644 --- a/kyu_4/sudoku_solution_validator/test_valid_solution.py +++ b/kyu_4/sudoku_solution_validator/test_valid_solution.py @@ -1,5 +1,6 @@ """ -Test for -> Sudoku Solution Validator +Test for -> Sudoku Solution Validator. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,12 +25,12 @@ @allure.link(url='https://www.codewars.com/kata/529bf0e9bdf7657179000008', name='Source/Kata') class ValidSolutionTestCase(unittest.TestCase): - """ - Testing validSolution function - """ + """Testing validSolution function.""" def test_valid_solution(self): """ + Test valid_solution function. + Test a function validSolution/ValidateSolution/valid_solution() that accepts a 2D array representing a Sudoku board, and returns true if it is a valid solution, or false otherwise. The cells of @@ -42,7 +43,7 @@ def test_valid_solution(self): :return: """ # pylint: disable-msg=R0801 - allure.dynamic.title("Testing validSolution") + allure.dynamic.title("Testing valid_solution") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '