diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml new file mode 100644 index 00000000000..f95a3be838c --- /dev/null +++ b/.github/workflows/flake8.yml @@ -0,0 +1,49 @@ +--- +name: Flake8 + +on: + 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 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 + flake8 . --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics + # yamllint enable rule:line-length \ No newline at end of file diff --git a/.github/workflows/flake8_kyu2.yml b/.github/workflows/flake8_kyu2.yml new file mode 100644 index 00000000000..3f848fe08e3 --- /dev/null +++ b/.github/workflows/flake8_kyu2.yml @@ -0,0 +1,47 @@ +--- +name: Flake8 for kyu2 + +on: + push: + branches: + - 'kyu2' + +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_2 + flake8 --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics ./kyu_2 + # yamllint enable rule:line-length \ No newline at end of file diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index ed075630fce..7cc548b3a67 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -11,4 +11,10 @@ jobs: uses: iKostanOrg/codewars/.github/workflows/markdown_lint.yml@master pyint: name: PyLint - uses: iKostanOrg/codewars/.github/workflows/pylint.yml@master \ No newline at end of file + uses: iKostanOrg/codewars/.github/workflows/pylint.yml@master + mypy: + name: MyPy Lint + uses: iKostanOrg/codewars/.github/workflows/mypy.yml@master + flake8: + name: Flake8 Lint + uses: iKostanOrg/codewars/.github/workflows/flake8.yml@master \ No newline at end of file diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 00000000000..770af5d41f1 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,65 @@ +name: MyPy Lint + +on: + 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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: kyu2 Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_2 --ignore-missing-imports --check-untyped-defs + - name: kyu_3 Python Data Type Checking with MyPy + run: | + mypy kyu_3 --ignore-missing-imports --check-untyped-defs + - name: kyu_4 Python Data Type Checking with MyPy + run: | + mypy kyu_4 --ignore-missing-imports --check-untyped-defs + - name: kyu_5 Python Data Type Checking with MyPy + run: | + mypy kyu_5 --ignore-missing-imports --check-untyped-defs + - name: kyu_6 Python Data Type Checking with MyPy + run: | + mypy kyu_6 --ignore-missing-imports --check-untyped-defs + - name: kyu_7 Python Data Type Checking with MyPy + run: | + mypy kyu_7 --ignore-missing-imports --check-untyped-defs + - name: kyu_8 Python Data Type Checking with MyPy + run: | + mypy kyu_8 --ignore-missing-imports --check-untyped-defs + - name: utils Python Data Type Checking with MyPy + run: | + mypy utils --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu2.yml b/.github/workflows/mypy_kyu2.yml new file mode 100644 index 00000000000..2cb637e0803 --- /dev/null +++ b/.github/workflows/mypy_kyu2.yml @@ -0,0 +1,42 @@ +name: MyPy for kyu2 + +on: + push: + branches: + - 'kyu2' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_2 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu4.yml b/.github/workflows/mypy_kyu4.yml new file mode 100644 index 00000000000..cc2e6105b9a --- /dev/null +++ b/.github/workflows/mypy_kyu4.yml @@ -0,0 +1,38 @@ +name: MyPy for kyu4 + +on: + push: + branches: + - 'kyu4' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_4 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu5.yml b/.github/workflows/mypy_kyu5.yml new file mode 100644 index 00000000000..a659b41c891 --- /dev/null +++ b/.github/workflows/mypy_kyu5.yml @@ -0,0 +1,38 @@ +name: MyPy for kyu5 + +on: + push: + branches: + - 'kyu5' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_5 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu6.yml b/.github/workflows/mypy_kyu6.yml new file mode 100644 index 00000000000..d3db064f238 --- /dev/null +++ b/.github/workflows/mypy_kyu6.yml @@ -0,0 +1,38 @@ +name: MyPy for kyu6 + +on: + push: + branches: + - 'kyu6' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_6 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu7.yml b/.github/workflows/mypy_kyu7.yml new file mode 100644 index 00000000000..ccda0d1275c --- /dev/null +++ b/.github/workflows/mypy_kyu7.yml @@ -0,0 +1,38 @@ +name: MyPy for kyu7 + +on: + push: + branches: + - 'kyu7' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_7 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/mypy_kyu8.yml b/.github/workflows/mypy_kyu8.yml new file mode 100644 index 00000000000..3fe6834c980 --- /dev/null +++ b/.github/workflows/mypy_kyu8.yml @@ -0,0 +1,38 @@ +name: MyPy for kyu8 + +on: + push: + branches: + - 'kyu8' + +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 mypy + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Python Data Type Checking with MyPy + # Python Type Checking (Guide) + # https://realpython.com/python-type-checking/ + run: | + mypy kyu_8 --ignore-missing-imports --check-untyped-defs diff --git a/.github/workflows/pylint_kyu2.yml b/.github/workflows/pylint_kyu2.yml index 368ade80ca9..617b211068a 100644 --- a/.github/workflows/pylint_kyu2.yml +++ b/.github/workflows/pylint_kyu2.yml @@ -5,6 +5,10 @@ on: branches: - 'kyu2' +permissions: + contents: read + pull-requests: read + jobs: build: runs-on: ubuntu-latest diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 178eb1973a1..6c297d42e48 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -51,50 +51,6 @@ def process_math_expression(string: str, operators: list) -> str: return ' '.join(strings) -def normalize_string(string: str) -> str: - """ - Normalizing string input - :param string: str - :return: str - """ - strings: list = [] - string_temp: str = ''.join([s for s in string if s != ' ']) - - while string_temp != '': - temp: str = '' - - for i, s in enumerate(string_temp): - if s.isdigit(): - temp += s - - if s in '()': - if temp != '': - strings.append(temp) - strings.append(s) - - if i + 1 < len(string_temp): - string_temp = string_temp[i + 1:] - else: - string_temp = '' - break - - if s in OPERATORS: - if temp != '': - strings.append(temp) - strings.append(s) - - if i + 1 < len(string_temp): - string_temp = string_temp[i + 1:] - break - - if i == len(string_temp) - 1: - if temp != '': - strings.append(temp) - string_temp = '' - - return ' '.join([s for s in strings if s != '']) - - def bracket_start(strings: list) -> int: """ Return index of first (open) bracket @@ -133,12 +89,12 @@ def process_brackets(strings: list) -> str: del strings[start] if len(strings[start + 1: end]) > 2: - temp = ' '.join(strings[start + 1: end]) + temp: str = ' '.join(strings[start + 1: end]) temp = process_duplicate_minus(temp) temp = process_math_expression(temp, ['*', '/']) - temp = [float(t) for t in temp.split() if t != '+'] - temp = str(sum(temp)) - tmp_strings = strings[:start] + temp_lst: list = [float(t) for t in temp.split() if t != '+'] + temp = str(sum(temp_lst)) + tmp_strings: list = strings[:start] tmp_strings.append(temp) if end < len(strings) - 1: tmp_strings += strings[end + 1:] @@ -180,7 +136,7 @@ def process_duplicate_minus(string: str) -> str: del strings[i] break - return ' '.join([s for s in strings if s != '']) + return ' '.join(strings) def calc(string: str) -> float: @@ -189,13 +145,59 @@ def calc(string: str) -> float: :param string: str :return: float """ - string = normalize_string(string) + string = ''.join([s for s in string if s != ' ']) + + strings: list = [] + while string: + temp: str = '' + temp, string = check_conditions(strings, string, temp) + string = ' '.join(strings) + string = ''.join(string.split('+')) strings = string.split() string = process_brackets(strings) string = process_duplicate_minus(string) string = process_math_expression(string, ['*', '/']) - string = string.split(' ') - string = [float(s) for s in string] - string = str(sum(string)) + string_lst: list = string.split(' ') + string_lst = [float(s) for s in string_lst] + string = str(sum(string_lst)) return float(string) + + +def check_conditions(strings: list, string: str, temp: str) -> tuple[str, str]: + """ + Normalizing string input by checking conditions + :param strings: list + :param string: str + :param temp: str + :return: tuple(str, str) + """ + for i, s in enumerate(string): + if s.isdigit(): + temp += s + + if (s in ''.join(OPERATORS) + '()' or i == len(string) - 1) and temp: + strings.append(temp) + + if s in '()': + strings.append(s) + + if i + 1 < len(string): + string = string[i + 1:] + else: + string = '' + + break + + if s in OPERATORS: + strings.append(s) + + if i + 1 < len(string): + string = string[i + 1:] + + break + + if i == len(string) - 1: + string = '' + + return temp, string diff --git a/kyu_2/evaluate_mathematical_expression/test_evaluate.py b/kyu_2/evaluate_mathematical_expression/test_evaluate.py index 9851b41495b..cb9f8073717 100644 --- a/kyu_2/evaluate_mathematical_expression/test_evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/test_evaluate.py @@ -78,8 +78,7 @@ def test_calc(self): ['-(-93) / (-36 + 26 + -(18)) + (-7 * -(((-(-67 + -95)))) + -9)', 1121.6785714285713], ['-(-23) + (-4 * -13 + -(1)) - (-30 / (((-(57 + -20)))) + 85)', -11.810810810810807], ['(72) / (-82 - -93 * -(88)) + (-18 - -(((-(60 * 97)))) + -79)', -5917.00871037987], - ['-(77) / (7 * -76 + (59)) + (98 / -(((-(-74 - -47)))) / -5)', 0.8887166236003445] - ) + ['-(77) / (7 * -76 + (59)) + (98 / -(((-(-74 - -47)))) / -5)', 0.8887166236003445]) for string, expected in test_data: diff --git a/kyu_3/README.md b/kyu_3/README.md index 625689a86b9..3a820446c22 100644 --- a/kyu_3/README.md +++ b/kyu_3/README.md @@ -16,11 +16,11 @@ rank - the harder the kata the faster you advance. ### List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|:--------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------:| -|1 | [Calculator](https://www.codewars.com/kata/5235c913397cbf2508000048) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/calculator) | -|2 | [Rail Fence Cipher: Encoding and Decoding](https://www.codewars.com/kata/58c5577d61aefcf3ff000081) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/rail_fence_cipher_encoding_and_decoding)| -|3 | [Make a spiral](https://www.codewars.com/kata/534e01fbbb17187c7e0000c6) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/make_spiral) | -|4 | [Battleship field validator](https://www.codewars.com/kata/52bb6539a4cf1b12d90005b7) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/battleship_field_validator) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:--------------------------------------------------------------------------------------------------:|----------------------------------------------------------------------------------------------------------:| +| 1 | [Calculator](https://www.codewars.com/kata/5235c913397cbf2508000048) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/calculator) | +| 2 | [Rail Fence Cipher: Encoding and Decoding](https://www.codewars.com/kata/58c5577d61aefcf3ff000081) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/rail_fence_cipher_encoding_and_decoding) | +| 3 | [Make a spiral](https://www.codewars.com/kata/534e01fbbb17187c7e0000c6) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/make_spiral) | +| 4 | [Battleship field validator](https://www.codewars.com/kata/52bb6539a4cf1b12d90005b7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_3/battleship_field_validator) | [Source](https://www.codewars.com/about) \ No newline at end of file diff --git a/kyu_3/rail_fence_cipher_encoding_and_decoding/test_decoding.py b/kyu_3/rail_fence_cipher_encoding_and_decoding/test_decoding.py index 5ffe2f5b0f2..e059def75e9 100644 --- a/kyu_3/rail_fence_cipher_encoding_and_decoding/test_decoding.py +++ b/kyu_3/rail_fence_cipher_encoding_and_decoding/test_decoding.py @@ -39,6 +39,7 @@ def test_decoding(self): """ Testing Decoding functionality """ + # pylint: disable-msg=R0801 allure.dynamic.title("Testing Decoding functionality") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( @@ -48,14 +49,13 @@ def test_decoding(self): '

Test Description:

' "

Verify cipher function. This \"decode\" is used " "to decode a string.

") - + # pylint: enable-msg=R0801 test_data: tuple = ( ("H !e,Wdloollr", 4, "Hello, World!"), ("WECRLTEERDSOEEFEAOCAIVDEN", 3, "WEAREDISCOVEREDFLEEATONCE"), ("", 3, ""), ("WEAREDISCOVEREDFLEEATONCE", 10, "WADCEDETNECOEFROIREESVELA"), - ("WEAREDISCOVEREDFLEEATONCE", 9, "WADCEDETCOEFROIREESVELANE") - ) + ("WEAREDISCOVEREDFLEEATONCE", 9, "WADCEDETCOEFROIREESVELANE")) # pylint: disable-msg=R0801 for string, n, expected in test_data: diff --git a/kyu_4/README.md b/kyu_4/README.md index a83fe39c4ab..fc3fb373705 100644 --- a/kyu_4/README.md +++ b/kyu_4/README.md @@ -16,21 +16,21 @@ rank - the harder the kata the faster you advance. ## List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|:------------------------------------------------------------------------------------------------------------------:|------------------------------------------------------------------------------------------------------------:| -|1 |[Sum of Intervals](https://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sum_of_intervals) | -|2 |[Human readable duration format](https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/human_readable_duration_format) | -|3 |[Sudoku Solution Validator](https://www.codewars.com/kata/529bf0e9bdf7657179000008/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sudoku_solution_validator) | -|4 |[Range Extraction](https://www.codewars.com/kata/51ba717bb08c1cd60f00002f/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/range_extraction) | -|5 |[Validate Sudoku with size `NxN`](https://www.codewars.com/kata/540afbe2dc9f615d5e000425/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/validate_sudoku_with_size) | -|6 |[Strip Comments](https://www.codewars.com/kata/51c8e37cee245da6b40000bd/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/strip_comments) | -|7 |[Snail](https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/snail) | -|8 |[Sum by Factors](https://www.codewars.com/kata/54d496788776e49e6b00052f) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sum_by_factors) | -|9 |[Most frequently used words in a text](https://www.codewars.com/kata/51e056fe544cf36c410000fb) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/most_frequently_used_words) | -|10 |[The Greatest Warrior](https://www.codewars.com/kata/5941c545f5c394fef900000c/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/the_greatest_warrior) | -|11 |[Strings Mix](https://www.codewars.com/kata/5629db57620258aa9d000014/solutions/python/all/newest) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/strings_mix) | -|12 |[Next smaller number with the same digits](https://www.codewars.com/kata/5659c6d896bc135c4c00021e/solutions/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/next_smaller_number_with_the_same_digits) | -|12 |[Next bigger number with the same digits](https://www.codewars.com/kata/55983863da40caa2c900004e/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/next_bigger_number_with_the_same_digits) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:--------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------:| +| 1 | [Sum of Intervals](https://www.codewars.com/kata/52b7ed099cdc285c300001cd) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sum_of_intervals) | +| 2 | [Human readable duration format](https://www.codewars.com/kata/52742f58faf5485cae000b9a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/human_readable_duration_format) | +| 3 | [Sudoku Solution Validator](https://www.codewars.com/kata/529bf0e9bdf7657179000008) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sudoku_solution_validator) | +| 4 | [Range Extraction](https://www.codewars.com/kata/51ba717bb08c1cd60f00002f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/range_extraction) | +| 5 | [Validate Sudoku with size `NxN`](https://www.codewars.com/kata/540afbe2dc9f615d5e000425) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/validate_sudoku_with_size) | +| 6 | [Strip Comments](https://www.codewars.com/kata/51c8e37cee245da6b40000bd) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/strip_comments) | +| 7 | [Snail](https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/snail) | +| 8 | [Sum by Factors](https://www.codewars.com/kata/54d496788776e49e6b00052f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/sum_by_factors) | +| 9 | [Most frequently used words in a text](https://www.codewars.com/kata/51e056fe544cf36c410000fb) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/most_frequently_used_words) | +| 10 | [The Greatest Warrior](https://www.codewars.com/kata/5941c545f5c394fef900000c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/the_greatest_warrior) | +| 11 | [Strings Mix](https://www.codewars.com/kata/5629db57620258aa9d000014) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/strings_mix) | +| 12 | [Next smaller number with the same digits](https://www.codewars.com/kata/5659c6d896bc135c4c00021e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/next_smaller_number_with_the_same_digits) | +| 12 | [Next bigger number with the same digits](https://www.codewars.com/kata/55983863da40caa2c900004e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_4/next_bigger_number_with_the_same_digits) | [Source](https://www.codewars.com/about) diff --git a/kyu_4/human_readable_duration_format/README.md b/kyu_4/human_readable_duration_format/README.md index f8c0f603d23..1b05bd961a3 100644 --- a/kyu_4/human_readable_duration_format/README.md +++ b/kyu_4/human_readable_duration_format/README.md @@ -42,4 +42,4 @@ not return 61 seconds, but `1 minute and 1 second` instead. Formally, the durati specified by of a component must not be greater than any valid more significant unit of time. -[Source](https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52742f58faf5485cae000b9a) \ No newline at end of file diff --git a/kyu_4/human_readable_duration_format/format_duration.py b/kyu_4/human_readable_duration_format/format_duration.py index f130ff8de6b..4065d79cb7d 100644 --- a/kyu_4/human_readable_duration_format/format_duration.py +++ b/kyu_4/human_readable_duration_format/format_duration.py @@ -1,7 +1,6 @@ """ A function which formats a duration, given as a number of seconds, in a human-friendly way. - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -43,13 +42,13 @@ def format_duration(seconds: int) -> str: if seconds == 0: return 'now' - result = '' + result: str = '' years: int = calc_years(seconds) days: int = calc_days(seconds) hours: int = calc_hours(seconds) minutes: int = calc_minutes(seconds) - seconds: int = calc_seconds(seconds) + seconds = calc_seconds(seconds) year: str = get_string(years, 'year') day: str = get_string(days, 'day') 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 e326e187d1f..0f498dc6ba2 100644 --- a/kyu_4/human_readable_duration_format/test_format_duration.py +++ b/kyu_4/human_readable_duration_format/test_format_duration.py @@ -1,6 +1,5 @@ """ Test for 'Human readable duration format' - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -10,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_4.human_readable_duration_format.format_duration import format_duration +from kyu_4.human_readable_duration_format.format_duration \ + import format_duration # pylint: disable-msg=R0801 @@ -23,8 +23,9 @@ @allure.tag('ALGORITHMS', 'FORMATS', 'STRINGS', - 'DATES/TIME', 'FORMATTING') -@allure.link(url='https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/python', + 'DATES/TIME', + 'FORMATTING') +@allure.link(url='https://www.codewars.com/kata/52742f58faf5485cae000b9a', name='Source/Kata') # pylint: enable-msg=R0801 class FormatDurationTestCase(unittest.TestCase): @@ -58,7 +59,7 @@ def test_format_duration(self): "the duration is expressed as a combination of years, " "days, hours, minutes and seconds.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (1, "1 second"), (62, "1 minute and 2 seconds"), (120, "2 minutes"), @@ -79,14 +80,14 @@ def test_format_duration(self): (33243586, '1 year, 19 days, 18 hours, 19 minutes and 46 seconds'), (9041160, - '104 days, 15 hours and 26 minutes'), - ] + '104 days, 15 hours and 26 minutes')) for seconds, expected in test_data: actual_result = format_duration(seconds) with allure.step(f"Enter seconds ({seconds}) and verify the " f"expected output ({expected}) vs " f"actual result ({actual_result})"): + print_log(seconds=seconds, expected=expected, result=actual_result) diff --git a/kyu_4/most_frequently_used_words/README.md b/kyu_4/most_frequently_used_words/README.md index b3c09b8b781..dc8cb0c904c 100644 --- a/kyu_4/most_frequently_used_words/README.md +++ b/kyu_4/most_frequently_used_words/README.md @@ -39,4 +39,4 @@ Bonus points (not really, but just for fun): input text. 2. Avoid sorting the entire array of unique words. -[Source](https://www.codewars.com/kata/51e056fe544cf36c410000fb/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/51e056fe544cf36c410000fb) \ No newline at end of file diff --git a/kyu_4/most_frequently_used_words/solution.py b/kyu_4/most_frequently_used_words/solution.py index d997a78d2c9..89813390c35 100644 --- a/kyu_4/most_frequently_used_words/solution.py +++ b/kyu_4/most_frequently_used_words/solution.py @@ -1,6 +1,5 @@ """ Most frequently used words in a text - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -18,8 +17,8 @@ def top_3_words(text: str) -> list: # 1 # Matches should be case-insensitive, and the words # in the result should be lower-cased. - illegals = ';/_?,.:!-' - text_lower = text.lower() + illegals: str = ';/_?,.:!-' + text_lower: str = text.lower() for char in illegals: text_lower = text_lower.replace(char, ' ') # 2 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 52f27cb3dbc..3e4c70af713 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,6 +1,5 @@ """ Test for 'Most frequently used words in a text' - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -10,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_4.most_frequently_used_words.solution import top_3_words +from kyu_4.most_frequently_used_words.solution \ + import top_3_words @allure.epic('4 kyu') @@ -25,7 +25,7 @@ 'RANKING', 'FILTERING') @allure.link( - url='https://www.codewars.com/kata/51e056fe544cf36c410000fb/train/python', + url='https://www.codewars.com/kata/51e056fe544cf36c410000fb', name='Source/Kata') class Top3WordsTestCase(unittest.TestCase): """ @@ -48,7 +48,7 @@ def test_top_3_words(self): "the function should return an array of the top-3 most occurring words, " "in descending order of the number of occurrences.

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("a a a b c c d d d d e e e e e", ["e", "d", "a"]), ("e e e e DDD ddd DdD: ddd ddd aa aA Aa, bb cc cC e e e", ["e", "ddd", "aa"]), (" //wont won't won't ", ["won't", "wont"]), @@ -89,8 +89,7 @@ def test_top_3_words(self): 'KdAFZ/KdAFZ-!_.:aqNSrVD._;VCDeGux_!QsF PVDdpw_,KdAFZ/ ;_/CUQhpOptV;.PVDdpw?/ ' ',rKlP:,uYVx? _-QsF-.VCDeGux-;;.wWHf,- QsF_rKlP:?.,/PVDdpw!,VCDeGux-:wWHf __;Q' 'sF,_.QsF:VCDeGux:', - ['aqywzhe', 'vcdegux', 'uyvx']) - ) + ['aqywzhe', 'vcdegux', 'uyvx'])) for text, expected in test_data: actual_result: list = top_3_words(text) diff --git a/kyu_4/next_bigger_number_with_the_same_digits/README.md b/kyu_4/next_bigger_number_with_the_same_digits/README.md index b4cadf6091d..1f1a9552ca5 100644 --- a/kyu_4/next_bigger_number_with_the_same_digits/README.md +++ b/kyu_4/next_bigger_number_with_the_same_digits/README.md @@ -17,4 +17,4 @@ If no bigger number can be composed using those digits, return `-1`: 531 ==> -1 ``` -[Source](https://www.codewars.com/kata/55983863da40caa2c900004e/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/55983863da40caa2c900004e) \ No newline at end of file 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 e6ce10f2a0e..889ff900f9b 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,6 +1,5 @@ """ Solution for -> Next bigger number with the same digits - Created by Egor Kostan. GitHub: https://github.com/ikostan """ 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 7c66ccbaabb..924c6be31c5 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,6 +1,5 @@ """ Test for -> Next bigger number with the same digits - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -10,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_4.next_bigger_number_with_the_same_digits.next_bigger import next_bigger +from kyu_4.next_bigger_number_with_the_same_digits.next_bigger \ + import next_bigger # pylint: disable-msg=R0801 @@ -25,7 +25,7 @@ 'STRINGS', 'INTEGERS', 'MATHEMATICS') -@allure.link(url='https://www.codewars.com/kata/55983863da40caa2c900004e/train/python', +@allure.link(url='https://www.codewars.com/kata/55983863da40caa2c900004e', name='Source/Kata') # pylint: enable-msg=R0801 class NextBiggerTestCase(unittest.TestCase): @@ -64,7 +64,7 @@ def test_next_bigger(self): "

If no bigger number can be composed using" " those digits, return -1

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (6, -1), (12, 21), (513, 531), @@ -72,8 +72,7 @@ def test_next_bigger(self): (414, 441), (144, 414), (6938652, 6952368), - (123456789, 123456798) - ] + (123456789, 123456798)) for n, expected in test_data: actual_result = next_bigger(n) 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 aae0dffdc82..a0dfe8eb090 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,6 +1,5 @@ """ Solution for -> Next smaller number with the same digits - Created by Egor Kostan. GitHub: https://github.com/ikostan """ 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 009f495fb87..0e1ad4b4264 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,6 +1,5 @@ """ Test for -> Next smaller number with the same digits - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -10,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_4.next_smaller_number_with_the_same_digits.next_smaller import next_smaller +from kyu_4.next_smaller_number_with_the_same_digits.next_smaller \ + import next_smaller # pylint: disable-msg=R0801 @@ -25,7 +25,7 @@ 'STRINGS', 'INTEGERS', 'MATHEMATICS') -@allure.link(url='https://www.codewars.com/kata/5659c6d896bc135c4c00021e/train/python', +@allure.link(url='https://www.codewars.com/kata/5659c6d896bc135c4c00021e', name='Source/Kata') # pylint: enable-msg=R0801 class NextSmallerTestCase(unittest.TestCase): @@ -64,7 +64,7 @@ def test_next_smaller(self): "

If no smaller number can be composed using those digits," " return -1

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (1027, -1), (1262347, 1247632), (907, 790), @@ -74,8 +74,7 @@ def test_next_smaller(self): (414, 144), (123456798, 123456789), (123456789, -1), - (1234567908, 1234567890), - ] + (1234567908, 1234567890)) for n, expected in test_data: actual_result = next_smaller(n) diff --git a/kyu_4/permutations/README.md b/kyu_4/permutations/README.md index 5a4ef7b3f6b..9962ffa90f8 100644 --- a/kyu_4/permutations/README.md +++ b/kyu_4/permutations/README.md @@ -14,4 +14,4 @@ permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa'] The order of the permutations doesn't matter. -[Source](https://www.codewars.com/kata/5254ca2719453dcc0b00027d/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5254ca2719453dcc0b00027d) \ No newline at end of file diff --git a/kyu_4/permutations/permutations.py b/kyu_4/permutations/permutations.py index 0d74e2c65d0..68cbdcf0c72 100644 --- a/kyu_4/permutations/permutations.py +++ b/kyu_4/permutations/permutations.py @@ -1,6 +1,5 @@ """ Solution for -. Permutations - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -13,5 +12,7 @@ def permutations(string: str) -> list: have to shuffle all letters from the input in all possible orders. """ - for char in string: - print(char) + for strg in string: + print(strg) + + return [] diff --git a/kyu_4/permutations/test_permutations.py b/kyu_4/permutations/test_permutations.py index f6fae617878..04a4ffaecd6 100644 --- a/kyu_4/permutations/test_permutations.py +++ b/kyu_4/permutations/test_permutations.py @@ -1,6 +1,5 @@ """ Solution for -. Permutations - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,7 +23,7 @@ @allure.tag('ALGORITHMS', 'PERMUTATIONS', 'STRINGS') -@allure.link(url='https://www.codewars.com/kata/5254ca2719453dcc0b00027d/train/python', +@allure.link(url='https://www.codewars.com/kata/5254ca2719453dcc0b00027d', name='Source/Kata') @pytest.mark.skip(reason="The solution is not ready") # pylint: enable-msg=R0801 @@ -58,7 +57,7 @@ def test_permutations(self): "have to shuffle all letters from the input in all " "possible orders.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ('a', ['a']), ('ab', ['ab', 'ba']), ('aabb', ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']), @@ -70,8 +69,7 @@ def test_permutations(self): ('dcba', ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', - 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) - ] + 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'])) # pylint: disable-msg=R0801 for string, expected in test_data: actual_result = sorted(permutations(string)) diff --git a/kyu_4/range_extraction/README.md b/kyu_4/range_extraction/README.md index 64cf61e7e26..c2d0fc5ca2b 100644 --- a/kyu_4/range_extraction/README.md +++ b/kyu_4/range_extraction/README.md @@ -22,4 +22,4 @@ solution([-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20 Courtesy of rosettacode.org -[Source](https://www.codewars.com/kata/51ba717bb08c1cd60f00002f/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/51ba717bb08c1cd60f00002f) \ No newline at end of file diff --git a/kyu_4/range_extraction/solution.py b/kyu_4/range_extraction/solution.py index f0ef211e994..6bdc4e98e02 100644 --- a/kyu_4/range_extraction/solution.py +++ b/kyu_4/range_extraction/solution.py @@ -1,6 +1,5 @@ """ Solution for -> Range Extraction - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -13,8 +12,8 @@ def solution(args: list) -> str: :param args: :return: """ - current = [args[0], args[0], False] - result = '' + current: list = [args[0], args[0], False] + result: str = '' for i, a in enumerate(args): diff --git a/kyu_4/range_extraction/test_solution.py b/kyu_4/range_extraction/test_solution.py index 5af58667bb1..e7ee7fc8465 100644 --- a/kyu_4/range_extraction/test_solution.py +++ b/kyu_4/range_extraction/test_solution.py @@ -1,6 +1,5 @@ """ Test for -> Range Extraction - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,7 +24,7 @@ 'FORMATTING', 'FORMATTING', 'STRINGS') -@allure.link(url='https://www.codewars.com/kata/51ba717bb08c1cd60f00002f/train/python', +@allure.link(url='https://www.codewars.com/kata/51ba717bb08c1cd60f00002f', name='Source/Kata') class SolutionTestCase(unittest.TestCase): """ @@ -36,7 +35,6 @@ def test_solution(self): """ Testing solution function """ - allure.dynamic.title("Testing solution function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( @@ -49,7 +47,7 @@ def test_solution(self): "in increasing order and returns a correctly formatted " "string in the range format.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ([-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20], '-6,-3-1,3-5,7-11,14,15,17-20'), @@ -57,8 +55,7 @@ def test_solution(self): '-3--1,2,10,15,16,18-20'), ([-91, -90, -87, -84, -81, -78, -77, -76, -74, -72, -70, -69, -66, -65, -63, -60, -58, -57, -54], - '-91,-90,-87,-84,-81,-78--76,-74,-72,-70,-69,-66,-65,-63,-60,-58,-57,-54') - ] + '-91,-90,-87,-84,-81,-78--76,-74,-72,-70,-69,-66,-65,-63,-60,-58,-57,-54')) for test_list, expected in test_data: actual_result = solution(test_list) diff --git a/kyu_4/snail/README.md b/kyu_4/snail/README.md index 2add6c35bb3..727f784aa74 100644 --- a/kyu_4/snail/README.md +++ b/kyu_4/snail/README.md @@ -31,4 +31,4 @@ the idea is to traverse the 2-d array in a clockwise snailshell pattern. NOTE 2: The 0x0 (empty matrix) is represented as en empty array inside an array `[[]]`. -[Source](https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1) \ No newline at end of file diff --git a/kyu_4/snail/snail_sort.py b/kyu_4/snail/snail_sort.py index 3eb2265a5de..34f614c1144 100644 --- a/kyu_4/snail/snail_sort.py +++ b/kyu_4/snail/snail_sort.py @@ -21,7 +21,8 @@ def snail(snail_map: list) -> list: if not snail_map: return [] - result = [] + result: list = [] + while snail_map: try: # 1 left to right diff --git a/kyu_4/snail/test_snail.py b/kyu_4/snail/test_snail.py index e5a92fe1899..4e92c26f8b3 100644 --- a/kyu_4/snail/test_snail.py +++ b/kyu_4/snail/test_snail.py @@ -25,7 +25,7 @@ @allure.tag('ALGORITHMS', 'ARRAYS', 'LISTS') -@allure.link(url='https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python', +@allure.link(url='https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1', name='Source/Kata') class SnailTestCase(unittest.TestCase): """ @@ -53,7 +53,7 @@ def test_snail(self): " middle element, " "traveling clockwise

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([[]], []), ([[1]], [1]), ([[1, 2, 3], @@ -78,8 +78,7 @@ def test_snail(self): 215, 121, 825, 295, 741, 124, 1, 437, 987, 431, 949, 675, 466, 182, 132, 846, 200, 383, 122, 371, 179, 76, 684, 268, 480, 256, 168, - 805, 672, 169, 173, 458, 568, 92, 107, 552, 884]) - ) + 805, 672, 169, 173, 458, 568, 92, 107, 552, 884])) for snail_map, expected in test_data: actual_result: list = snail(snail_map) diff --git a/kyu_4/strings_mix/README.md b/kyu_4/strings_mix/README.md index dfcd093a5f8..c09c168468d 100644 --- a/kyu_4/strings_mix/README.md +++ b/kyu_4/strings_mix/README.md @@ -66,4 +66,4 @@ mix(s1, s2) --> "1:mmmmmm/E:nnnnnn/1:aaaa/1:hhh/2:yyy/2:dd/2:ff/2:ii/2:rr/E:ee/E ``` -[Source](https://www.codewars.com/kata/5629db57620258aa9d000014/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5629db57620258aa9d000014) \ No newline at end of file diff --git a/kyu_4/strings_mix/solution.py b/kyu_4/strings_mix/solution.py index b2d51fa51f8..a73966a0bfa 100644 --- a/kyu_4/strings_mix/solution.py +++ b/kyu_4/strings_mix/solution.py @@ -1,6 +1,5 @@ """ Solution for -> Strings Mix - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -56,7 +55,7 @@ def sort_results(results: list) -> list: :param results: :return: """ - results: list = sorted(results) + results = sorted(results) is_sorted: bool = False while not is_sorted: diff --git a/kyu_4/strings_mix/test_mix.py b/kyu_4/strings_mix/test_mix.py index 62eb3e845f6..dec95adf8cd 100644 --- a/kyu_4/strings_mix/test_mix.py +++ b/kyu_4/strings_mix/test_mix.py @@ -1,6 +1,5 @@ """ Test for -> Strings Mix - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -22,7 +21,7 @@ @allure.tag('FUNDAMENTALS', 'STRINGS') @allure.link( - url='https://www.codewars.com/kata/5629db57620258aa9d000014/train/python', + url='https://www.codewars.com/kata/5629db57620258aa9d000014', name='Source/Kata') class MixTestCase(unittest.TestCase): """ @@ -49,7 +48,7 @@ def test_smix(self): "take into account the lowercase letters (a to z). First let " "us count the frequency of each lowercase letters in s1 and s2.

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("Are they here", "yes, they are here", "2:eeeee/2:yy/=:hh/=:rr"), @@ -67,8 +66,7 @@ def test_smix(self): "",), ("A generation must confront the looming ", "codewarrs", - "1:nnnnn/1:ooooo/1:tttt/1:eee/1:gg/1:ii/1:mm/=:rr"), - ) + "1:nnnnn/1:ooooo/1:tttt/1:eee/1:gg/1:ii/1:mm/=:rr")) for s1, s2, expected in test_data: actual_result = mix(s1, s2) diff --git a/kyu_4/strip_comments/README.md b/kyu_4/strip_comments/README.md index b844b0d18cb..3c4437bee54 100644 --- a/kyu_4/strip_comments/README.md +++ b/kyu_4/strip_comments/README.md @@ -31,4 +31,4 @@ result = solution("apples, pears # and bananas\ngrapes\nbananas !apples", ["#", ``` -[Source](https://www.codewars.com/kata/51c8e37cee245da6b40000bd/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/51c8e37cee245da6b40000bd) \ No newline at end of file diff --git a/kyu_4/strip_comments/solution.py b/kyu_4/strip_comments/solution.py index c3df8d8b22f..6a3b065b3f5 100644 --- a/kyu_4/strip_comments/solution.py +++ b/kyu_4/strip_comments/solution.py @@ -1,6 +1,5 @@ """ Solution for -> Strip Comments - Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_4/strip_comments/test_solution.py b/kyu_4/strip_comments/test_solution.py index a6dbf5a05a0..68e78a365c7 100644 --- a/kyu_4/strip_comments/test_solution.py +++ b/kyu_4/strip_comments/test_solution.py @@ -1,6 +1,5 @@ """ Test for -> Strip Comments - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -21,7 +20,7 @@ @allure.story("Strip Comments") @allure.tag('ALGORITHMS', 'STRINGS') -@allure.link(url='https://www.codewars.com/kata/51c8e37cee245da6b40000bd/train/python', +@allure.link(url='https://www.codewars.com/kata/51c8e37cee245da6b40000bd', name='Source/Kata') class SolutionTestCase(unittest.TestCase): """ @@ -49,14 +48,13 @@ def test_solution(self): "of a set of comment markers passed in. Any whitespace at " "the end of the line should also be stripped out.

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("apples, pears # and bananas\ngrapes\nbananas !apples", ["#", "!"], "apples, pears\ngrapes\nbananas"), ("a #b\nc\nd $e f g", ["#", "$"], - "a\nc\nd"), - ) + "a\nc\nd")) for string, markers, expected in test_data: actual_result = solution(string, markers) diff --git a/kyu_4/sudoku_solution_validator/README.md b/kyu_4/sudoku_solution_validator/README.md index c0e8f2c9888..a91d425082e 100644 --- a/kyu_4/sudoku_solution_validator/README.md +++ b/kyu_4/sudoku_solution_validator/README.md @@ -45,4 +45,4 @@ validSolution([ ]); // => false ``` -[Source](https://www.codewars.com/kata/529bf0e9bdf7657179000008/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/529bf0e9bdf7657179000008) \ No newline at end of file diff --git a/kyu_4/sudoku_solution_validator/test_valid_solution.py b/kyu_4/sudoku_solution_validator/test_valid_solution.py index bb6f5533b48..a0c08843d60 100644 --- a/kyu_4/sudoku_solution_validator/test_valid_solution.py +++ b/kyu_4/sudoku_solution_validator/test_valid_solution.py @@ -1,6 +1,5 @@ """ Test for -> Sudoku Solution Validator - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,7 +8,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_4.sudoku_solution_validator.valid_solution import valid_solution +from kyu_4.sudoku_solution_validator.valid_solution \ + import valid_solution @allure.epic('4 kyu') @@ -21,7 +21,7 @@ @allure.tag('ALGORITHMS', 'DATA STRUCTURES', 'VALIDATION') -@allure.link(url='https://www.codewars.com/kata/529bf0e9bdf7657179000008/train/python', +@allure.link(url='https://www.codewars.com/kata/529bf0e9bdf7657179000008', name='Source/Kata') class ValidSolutionTestCase(unittest.TestCase): """ @@ -61,7 +61,7 @@ def test_valid_solution(self): " and every cell only contains integers from" " 0 to 9.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ([[5, 3, 4, 6, 7, 8, 9, 1, 2], [6, 7, 2, 1, 9, 5, 3, 4, 8], [1, 9, 8, 3, 4, 2, 5, 6, 7], @@ -90,7 +90,7 @@ def test_valid_solution(self): [6, 7, 8, 9, 1, 2, 3, 4, 5], [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 1, 2, 3, 4, 5, 6, 7], - [9, 1, 2, 3, 4, 5, 6, 7, 8]], False)] + [9, 1, 2, 3, 4, 5, 6, 7, 8]], False)) for data in test_data: board = data[0] diff --git a/kyu_4/sudoku_solution_validator/valid_solution.py b/kyu_4/sudoku_solution_validator/valid_solution.py index 143a3097fb4..64530a3a2cc 100644 --- a/kyu_4/sudoku_solution_validator/valid_solution.py +++ b/kyu_4/sudoku_solution_validator/valid_solution.py @@ -1,6 +1,5 @@ """ Solution for -> Sudoku Solution Validator - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,7 +24,6 @@ def check_horizontally(board: list) -> bool: :param board: :return: """ - for row in board: if sorted(row) != [1, 2, 3, 4, 5, 6, 7, 8, 9]: return False @@ -38,8 +36,8 @@ def check_vertically(board: list) -> bool: :param board: :return: """ + i: int = 0 - i = 0 while i < 9: col = [] for row in board: @@ -57,8 +55,7 @@ def check_sub_grids(board: list) -> bool: :param board: :return: """ - - sub_grids = [ + sub_grids: list = [ board[0][0:3] + board[1][0:3] + board[2][0:3], board[0][3:6] + board[1][3:6] + board[2][3:6], board[0][6:] + board[1][6:] + board[2][6:], diff --git a/kyu_4/sum_by_factors/README.md b/kyu_4/sum_by_factors/README.md index 19017945277..1dbf7de8bcd 100644 --- a/kyu_4/sum_by_factors/README.md +++ b/kyu_4/sum_by_factors/README.md @@ -35,4 +35,4 @@ we have `[5, 0]` in the result amongst others. permitted to contain any redundant trailing whitespace: you can use dynamically allocated character strings. -[Source](https://www.codewars.com/kata/54d496788776e49e6b00052f/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/54d496788776e49e6b00052f) \ No newline at end of file diff --git a/kyu_4/sum_by_factors/sum_for_list.py b/kyu_4/sum_by_factors/sum_for_list.py index 24c83adb75a..c5669a25289 100644 --- a/kyu_4/sum_by_factors/sum_for_list.py +++ b/kyu_4/sum_by_factors/sum_for_list.py @@ -1,6 +1,5 @@ """ Solution for -> sum_for_list function - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -21,7 +20,7 @@ def sum_for_list(lst: list) -> list: :return: sorted array P """ max_l = max(lst) if abs(max(lst)) > abs(min(lst)) else abs(min(lst)) - results = [] + results: list = [] for prime in gen_primes(): # stop execution in case current diff --git a/kyu_4/sum_by_factors/test_sum_for_list.py b/kyu_4/sum_by_factors/test_sum_for_list.py index 3a0093bdcb9..ca05d5c0615 100644 --- a/kyu_4/sum_by_factors/test_sum_for_list.py +++ b/kyu_4/sum_by_factors/test_sum_for_list.py @@ -1,6 +1,5 @@ """ Testing sum_for_list function - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -23,7 +22,7 @@ 'NUMBERS', 'ARRAYS') @allure.link( - url='https://www.codewars.com/kata/54d496788776e49e6b00052f/train/python', + url='https://www.codewars.com/kata/54d496788776e49e6b00052f', name='Source/Kata') class SumForListTestCase(unittest.TestCase): """ @@ -49,7 +48,7 @@ def test_sum_for_list(self): "[[p, sum of all ij of I for which p is a prime factor (p positive) of ij]...]" "

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([12, 15], [[2, 12], [3, 27], [5, 15]]), ([15, 21, 24, 30, 45], @@ -69,8 +68,7 @@ def test_sum_for_list(self): [37, -37], [41, -164], [113, -113], [131, 131], [191, -191]]), ([12, -138, -175, -64, -153, 11, -11, -126, -67, -30, 153, -72, -102], [[2, -520], [3, -456], [5, -205], [7, -301], [11, 0], [17, -102], [23, -138], - [67, -67]]) - ) + [67, -67]])) for lst, expected in test_data: diff --git a/kyu_4/sum_of_intervals/README.md b/kyu_4/sum_of_intervals/README.md index 458236a8c5d..d74487912b4 100644 --- a/kyu_4/sum_of_intervals/README.md +++ b/kyu_4/sum_of_intervals/README.md @@ -50,4 +50,4 @@ sumIntervals( [ ] ); // => 19 ``` -[Source](https://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52b7ed099cdc285c300001cd) \ No newline at end of file diff --git a/kyu_4/sum_of_intervals/sum_of_intervals.py b/kyu_4/sum_of_intervals/sum_of_intervals.py index b7af7ba3312..0130532696e 100644 --- a/kyu_4/sum_of_intervals/sum_of_intervals.py +++ b/kyu_4/sum_of_intervals/sum_of_intervals.py @@ -1,6 +1,5 @@ """ Solution for -> Sum of Intervals - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -17,7 +16,7 @@ def sum_of_intervals(intervals: list) -> int: """ intervals = remove_overlaps(intervals) - results = [] + results: list = [] for i in intervals: results.append(i[1] - i[0]) @@ -27,12 +26,12 @@ def sum_of_intervals(intervals: list) -> int: def remove_overlaps(intervals: list) -> list: """ -Remove overlaps and duplicates -:param intervals: -:return: -""" + Remove overlaps and duplicates + :param intervals: + :return: + """ + is_clean: bool = False - is_clean = False while not is_clean: is_clean = True @@ -54,8 +53,7 @@ def clean_interval(intervals, i, b) -> bool: :param b: :return: """ - - result = True + result: bool = True if i[0] == b[0] and i[1] == b[1]: intervals.remove(b) diff --git a/kyu_4/sum_of_intervals/test_sum_of_intervals.py b/kyu_4/sum_of_intervals/test_sum_of_intervals.py index 115de81361d..29d7c9e6923 100644 --- a/kyu_4/sum_of_intervals/test_sum_of_intervals.py +++ b/kyu_4/sum_of_intervals/test_sum_of_intervals.py @@ -1,6 +1,5 @@ """ Test for -> Sum of Intervals - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,7 +24,7 @@ 'MATHEMATICS', 'NUMBERS', 'INTEGERS') -@allure.link(url='https://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/python', +@allure.link(url='https://www.codewars.com/kata/52b7ed099cdc285c300001cd', name='Source/Kata') class SumOfIntervalsTestCase(unittest.TestCase): """ @@ -68,7 +67,7 @@ def test_sum_of_intervals(self): " Interval example: [1, 5] is an interval from 1 to 5." " The length of this interval is 4.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ([(1, 5)], 4), ([(1, 5), (6, 10)], 8), ([(1, 5), (1, 5)], 4), @@ -89,8 +88,7 @@ def test_sum_of_intervals(self): ([(289, 353), (342, 351), (-231, 202), (-304, -194), (31, 277), (-73, 247), (-371, -262), (77, 436), (368, 420), (235, 295), (-135, 294), (204, 325), (14, 344), (456, 494), (-500, 288), (326, 360), (313, 379), (-260, -94), - (93, 328), (456, 493)], 974) - ] + (93, 328), (456, 493)], 974)) for intervals, expected in test_data: actual_result = sum_of_intervals(intervals) diff --git a/kyu_4/the_greatest_warrior/README.md b/kyu_4/the_greatest_warrior/README.md index d3855972350..29c540548b7 100644 --- a/kyu_4/the_greatest_warrior/README.md +++ b/kyu_4/the_greatest_warrior/README.md @@ -100,4 +100,4 @@ bruce_lee.achievements # => ["Defeated Chuck Norris"] ``` -[Source](https://www.codewars.com/kata/5941c545f5c394fef900000c/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5941c545f5c394fef900000c) \ No newline at end of file diff --git a/kyu_4/the_greatest_warrior/test_battle.py b/kyu_4/the_greatest_warrior/test_battle.py index 70cd2d24a68..811d30edc09 100644 --- a/kyu_4/the_greatest_warrior/test_battle.py +++ b/kyu_4/the_greatest_warrior/test_battle.py @@ -1,18 +1,18 @@ """ Test for -> The Greatest Warrior -> test battle - Created by Egor Kostan. GitHub: https://github.com/ikostan """ -# ALGORITHMS CLASSES BASIC LANGUAGE FEATURES OBJECT-ORIENTED PROGRAMMING -# FUNDAMENTALS RULES +# ALGORITHMS CLASSES BASIC LANGUAGE FEATURES +# OBJECT-ORIENTED PROGRAMMING FUNDAMENTALS RULES import unittest import allure from kyu_4.the_greatest_warrior.warrior import Warrior +# pylint: disable-msg=R0801 @allure.epic('4 kyu') @allure.parent_suite('Competent') @allure.suite('OOP') @@ -26,8 +26,9 @@ 'FUNDAMENTALS', 'RULES') @allure.link( - url='https://www.codewars.com/kata/5941c545f5c394fef900000c/train/python', + url='https://www.codewars.com/kata/5941c545f5c394fef900000c', name='Source/Kata') +# pylint: enable-msg=R0801 class BattleTestCase(unittest.TestCase): """ Testing Battle method diff --git a/kyu_4/the_greatest_warrior/test_warrior.py b/kyu_4/the_greatest_warrior/test_warrior.py index 0f20187cb1a..c4256f1c0b0 100644 --- a/kyu_4/the_greatest_warrior/test_warrior.py +++ b/kyu_4/the_greatest_warrior/test_warrior.py @@ -1,12 +1,11 @@ """ Test for -> The Greatest Warrior -> test warrior - Created by Egor Kostan. GitHub: https://github.com/ikostan """ -# ALGORITHMS CLASSES BASIC LANGUAGE FEATURES OBJECT-ORIENTED PROGRAMMING -# FUNDAMENTALS RULES +# ALGORITHMS CLASSES BASIC LANGUAGE FEATURES +# OBJECT-ORIENTED PROGRAMMING FUNDAMENTALS RULES import unittest import allure @@ -28,7 +27,7 @@ 'FUNDAMENTALS', 'RULES') @allure.link( - url='https://www.codewars.com/kata/5941c545f5c394fef900000c/train/python', + url='https://www.codewars.com/kata/5941c545f5c394fef900000c', name='Source/Kata') # pylint: enable-msg=R0801 class WarriorTestCase(unittest.TestCase): diff --git a/kyu_4/the_greatest_warrior/warrior.py b/kyu_4/the_greatest_warrior/warrior.py index f370a6659a6..f225b1c8666 100644 --- a/kyu_4/the_greatest_warrior/warrior.py +++ b/kyu_4/the_greatest_warrior/warrior.py @@ -1,6 +1,5 @@ """ Solution for -> The Greatest Warrior - Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_4/validate_sudoku_with_size/README.md b/kyu_4/validate_sudoku_with_size/README.md index 9f422e3f954..4e8870adf3b 100644 --- a/kyu_4/validate_sudoku_with_size/README.md +++ b/kyu_4/validate_sudoku_with_size/README.md @@ -32,4 +32,4 @@ ie: Note: the matrix may include non-integer elements. -[Source](https://www.codewars.com/kata/540afbe2dc9f615d5e000425/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/540afbe2dc9f615d5e000425) \ No newline at end of file diff --git a/kyu_4/validate_sudoku_with_size/sudoku.py b/kyu_4/validate_sudoku_with_size/sudoku.py index 5ede145dd7b..690964f1d95 100644 --- a/kyu_4/validate_sudoku_with_size/sudoku.py +++ b/kyu_4/validate_sudoku_with_size/sudoku.py @@ -1,14 +1,16 @@ """ Solution for -> Validate Sudoku with size `NxN` - Created by Egor Kostan. GitHub: https://github.com/ikostan """ -from kyu_5.did_i_finish_my_sudoku.sudoku_by_row import assert_sudoku_by_row -from kyu_5.did_i_finish_my_sudoku.sudoku_by_column import assert_sudoku_by_column -from kyu_5.did_i_finish_my_sudoku.sudoku_by_regions import assert_sudoku_by_region +from kyu_5.did_i_finish_my_sudoku.sudoku_by_row \ + import assert_sudoku_by_row +from kyu_5.did_i_finish_my_sudoku.sudoku_by_column \ + import assert_sudoku_by_column +from kyu_5.did_i_finish_my_sudoku.sudoku_by_regions \ + import assert_sudoku_by_region class Sudoku: diff --git a/kyu_4/validate_sudoku_with_size/test_sudoku.py b/kyu_4/validate_sudoku_with_size/test_sudoku.py index 8a3ef98029f..7f4ad1a461d 100644 --- a/kyu_4/validate_sudoku_with_size/test_sudoku.py +++ b/kyu_4/validate_sudoku_with_size/test_sudoku.py @@ -1,6 +1,5 @@ """ Test for -> Validate Sudoku with size `NxN` - Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,8 +23,9 @@ 'GAMES', 'ALGORITHMS', 'VALIDATION') -@allure.link(url='https://www.codewars.com/kata/540afbe2dc9f615d5e000425/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/540afbe2dc9f615d5e000425', + name='Source/Kata') class SudokuTestCase(unittest.TestCase): """ Testing Sudoku class @@ -52,7 +52,7 @@ def test_sudoku_class(self): "N > 0 and √N == integer, assert a method that validates " "if it has been filled out correctly.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ([ [7, 8, 4, 1, 5, 9, 3, 2, 6], [5, 3, 9, 6, 7, 2, 8, 4, 1], @@ -160,9 +160,7 @@ def test_sudoku_class(self): [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 7, 2, 3, 1, 5, 6, 4], [9, 7, 8, 3, 1, 2, 6, 4, 5]], - False, 'Sudoku with invalid boxes (little squares), but valid rows and columns'), - - ] + False, 'Sudoku with invalid boxes (little squares), but valid rows and columns')) for data, expected, message in test_data: with allure.step("Enter a Sudoku solution and verify if it a valid one."): diff --git a/kyu_5/README.md b/kyu_5/README.md index 41afd3c6b04..9be3c9268b6 100644 --- a/kyu_5/README.md +++ b/kyu_5/README.md @@ -15,30 +15,30 @@ rank - the harder the kata the faster you advance. ### List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|:------------------------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------:| -|1 |[Fibonacci Streaming](https://www.codewars.com/kata/55695bc4f75bbaea5100016b/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/fibonacci_streaming) | -|2 |[Not very secure](https://www.codewars.com/kata/526dbd6c8c0eb53254000110/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/not_very_secure) | -|3 |[Simple Pig Latin](https://www.codewars.com/kata/520b9d2ad5c005041100000f/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/simple_pig_latin) | -|4 |[Human Readable Time](https://www.codewars.com/kata/52685f7382004e774f0001f7/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/human_readable_time) | -|5 |[Alphabet wars - nuclear strike](https://www.codewars.com/kata/alphabet-wars-nuclear-strike/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/alphabet_wars_nuclear_strike) | -|6 |[Valid Parentheses](https://www.codewars.com/kata/52774a314c2333f0a7000688/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/valid_parentheses) | -|7 |[Moving Zeros To The End](https://www.codewars.com/kata/52597aa56021e91c93000cb0/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/moving_zeros_to_the_end) | -|8 |[Directions Reduction](https://www.codewars.com/kata/550f22f4d758534c1100025a/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/directions_reduction) | -|9 |[Where my anagrams at?](https://www.codewars.com/kata/523a86aa4230ebb5420001e1/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/where_my_anagrams_at) | -|10 |[Master your primes: sieve with memoization](https://www.codewars.com/kata/58603c898989d15e9e000475/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/master_your_primes_sieve_with_memoization) | -|11 |[Number of trailing zeros of N!](https://www.codewars.com/kata/52f787eb172a8b4ae1000a34/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/number_of_trailing_zeros_of_n) | -|12 |[flatten](https://www.codewars.com/kata/513fa1d75e4297ba38000003/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/flatten) | -|13 |[First non-repeating character](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/first_non_repeating_character) | -|14 |[Sports League Table Ranking](https://www.codewars.com/kata/5e0baea9d772160032022e8c/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/sports_league_table_ranking) | -|15 |[Find the safest places in town](https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/find_the_safest_places_in_town) | -|16 |[Did I Finish my Sudoku?](https://www.codewars.com/kata/53db96041f1a7d32dc0004d2/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/did_i_finish_my_sudoku) | -|17 |[Extract the domain name from a URL](https://www.codewars.com/kata/514a024011ea4fb54200004b/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/extract_the_domain_name_from_url) | -|18 |[The Hashtag Generator](https://www.codewars.com/kata/52449b062fb80683ec000024/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/the_hashtag_generator) | -|19 |[Sum of Pairs](https://www.codewars.com/kata/54d81488b981293527000c8f/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/sum_of_pairs) | -|20 |[Tic-Tac-Toe Checker](https://www.codewars.com/kata/525caa5c1bf619d28c000335/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/tic_tac_toe_checker) | -|21 |[String incrementer](https://www.codewars.com/kata/54a91a4883a7de5d7800009c/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/string_incrementer) | -|22 |[Find the smallest](https://www.codewars.com/kata/573992c724fc289553000e95/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/find_the_smallest) | -|23 |[Integers: Recreation One](https://www.codewars.com/kata/55aa075506463dac6600010d/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/integers_recreation_one) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:----------------------------------------------------------------------------------------------------:|------------------------------------------------------------------------------------------------------------:| +| 1 | [Fibonacci Streaming](https://www.codewars.com/kata/55695bc4f75bbaea5100016b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/fibonacci_streaming) | +| 2 | [Not very secure](https://www.codewars.com/kata/526dbd6c8c0eb53254000110) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/not_very_secure) | +| 3 | [Simple Pig Latin](https://www.codewars.com/kata/520b9d2ad5c005041100000f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/simple_pig_latin) | +| 4 | [Human Readable Time](https://www.codewars.com/kata/52685f7382004e774f0001f7) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/human_readable_time) | +| 5 | [Alphabet wars - nuclear strike](https://www.codewars.com/kata/alphabet-wars-nuclear-strike) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/alphabet_wars_nuclear_strike) | +| 6 | [Valid Parentheses](https://www.codewars.com/kata/52774a314c2333f0a7000688) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/valid_parentheses) | +| 7 | [Moving Zeros To The End](https://www.codewars.com/kata/52597aa56021e91c93000cb0) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/moving_zeros_to_the_end) | +| 8 | [Directions Reduction](https://www.codewars.com/kata/550f22f4d758534c1100025a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/directions_reduction) | +| 9 | [Where my anagrams at?](https://www.codewars.com/kata/523a86aa4230ebb5420001e1) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/where_my_anagrams_at) | +| 10 | [Master your primes: sieve with memoization](https://www.codewars.com/kata/58603c898989d15e9e000475) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/master_your_primes_sieve_with_memoization) | +| 11 | [Number of trailing zeros of N!](https://www.codewars.com/kata/52f787eb172a8b4ae1000a34) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/number_of_trailing_zeros_of_n) | +| 12 | [flatten](https://www.codewars.com/kata/513fa1d75e4297ba38000003) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/flatten) | +| 13 | [First non-repeating character](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/first_non_repeating_character) | +| 14 | [Sports League Table Ranking](https://www.codewars.com/kata/5e0baea9d772160032022e8c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/sports_league_table_ranking) | +| 15 | [Find the safest places in town](https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/find_the_safest_places_in_town) | +| 16 | [Did I Finish my Sudoku?](https://www.codewars.com/kata/53db96041f1a7d32dc0004d2) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/did_i_finish_my_sudoku) | +| 17 | [Extract the domain name from a URL](https://www.codewars.com/kata/514a024011ea4fb54200004b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/extract_the_domain_name_from_url) | +| 18 | [The Hashtag Generator](https://www.codewars.com/kata/52449b062fb80683ec000024) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/the_hashtag_generator) | +| 19 | [Sum of Pairs](https://www.codewars.com/kata/54d81488b981293527000c8f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/sum_of_pairs) | +| 20 | [Tic-Tac-Toe Checker](https://www.codewars.com/kata/525caa5c1bf619d28c000335) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/tic_tac_toe_checker) | +| 21 | [String incrementer](https://www.codewars.com/kata/54a91a4883a7de5d7800009c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/string_incrementer) | +| 22 | [Find the smallest](https://www.codewars.com/kata/573992c724fc289553000e95) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/find_the_smallest) | +| 23 | [Integers: Recreation One](https://www.codewars.com/kata/55aa075506463dac6600010d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_5/integers_recreation_one) | [Source](https://www.codewars.com/about) \ No newline at end of file diff --git a/kyu_5/alphabet_wars_nuclear_strike/README.md b/kyu_5/alphabet_wars_nuclear_strike/README.md index 97a1b7b2d14..fa697ccad1f 100644 --- a/kyu_5/alphabet_wars_nuclear_strike/README.md +++ b/kyu_5/alphabet_wars_nuclear_strike/README.md @@ -41,4 +41,4 @@ ab#de[fgh]ij#k => "" (all letters dies, there are 2 # close to the shellter ) ``` -[Source](https://www.codewars.com/kata/alphabet-wars-nuclear-strike/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/alphabet-wars-nuclear-strike) \ No newline at end of file diff --git a/kyu_5/alphabet_wars_nuclear_strike/alphabet_war.py b/kyu_5/alphabet_wars_nuclear_strike/alphabet_war.py index 10552e4fb35..884fb301213 100644 --- a/kyu_5/alphabet_wars_nuclear_strike/alphabet_war.py +++ b/kyu_5/alphabet_wars_nuclear_strike/alphabet_war.py @@ -17,7 +17,7 @@ def alphabet_war(battlefield: str) -> str: return ''.join(char for char in battlefield if char.isalpha()) result: str = clean_unsheltered(battlefield) - result: str = clean_battlefield(result) + result = clean_battlefield(result) return result @@ -52,8 +52,8 @@ def clean_battlefield(battlefield: str) -> str: :return: str """ result: list = battlefield.split('[') - result: list = [string for string in result if string != ''] - result: list = list(reversed(result)) + result = [string for string in result if string != ''] + result = list(reversed(result)) temp: list = [] while result: diff --git a/kyu_5/alphabet_wars_nuclear_strike/test_alphabet_war.py b/kyu_5/alphabet_wars_nuclear_strike/test_alphabet_war.py index d0ed584d9b8..8ae7af8c3b5 100644 --- a/kyu_5/alphabet_wars_nuclear_strike/test_alphabet_war.py +++ b/kyu_5/alphabet_wars_nuclear_strike/test_alphabet_war.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.alphabet_wars_nuclear_strike.alphabet_war import alphabet_war +from kyu_5.alphabet_wars_nuclear_strike.alphabet_war \ + import alphabet_war # pylint: disable-msg=R0801 @@ -29,8 +30,9 @@ 'ADVANCED', 'LANGUAGE', 'FEATURES') -@allure.link(url='https://www.codewars.com/kata/alphabet-wars-nuclear-strike/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/alphabet-wars-nuclear-strike', + name='Source/Kata') # pylint: enable-msg=R0801 class AlphabetWarTestCase(unittest.TestCase): """ @@ -80,7 +82,7 @@ def test_alphabet_war(self): "

Test a function that accepts battlefield string and " "returns letters that survived the nuclear strike.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ('[a]#[b]#[c]', 'ac'), ('[a]#b#[c][d]', 'd'), ('[a][b][c]', 'abc'), @@ -94,15 +96,15 @@ def test_alphabet_war(self): ('abcde[fgh]', 'abcdefgh'), ('##abde[fgh]ijk[mn]op', 'mn'), ('#abde[fgh]i#jk[mn]op', 'mn'), - ('[ab]adfd[dd]##[abe]dedf[ijk]d#d[h]#', 'abijk'), - ] + ('[ab]adfd[dd]##[abe]dedf[ijk]d#d[h]#', 'abijk')) for battlefield, expected in test_data: - result = alphabet_war(battlefield) + result: str = alphabet_war(battlefield) with allure.step(f"Enter test string ({battlefield}) " f"and verify the output ({result}) " f"vs expected ({expected})"): + print_log(battlefield=battlefield, result=result, expected=expected) diff --git a/kyu_5/count_ip_addresses/README.md b/kyu_5/count_ip_addresses/README.md index 0d5375caf9d..4e21c44a9d8 100644 --- a/kyu_5/count_ip_addresses/README.md +++ b/kyu_5/count_ip_addresses/README.md @@ -15,4 +15,4 @@ The last address will always be greater than the first one. > ips_between("20.0.0.10", "20.0.1.0") == 246 ``` -[Source](https://www.codewars.com/kata/526989a41034285187000de4/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/526989a41034285187000de4) \ No newline at end of file diff --git a/kyu_5/count_ip_addresses/ips_between.py b/kyu_5/count_ip_addresses/ips_between.py index 4e3b7e99f1f..50217783820 100644 --- a/kyu_5/count_ip_addresses/ips_between.py +++ b/kyu_5/count_ip_addresses/ips_between.py @@ -20,10 +20,10 @@ def ips_between(start: str, end: str) -> int: :return: int """ - ip_start = [int(a) for a in start.split('.')] - ip_end = [int(b) for b in end.split('.')] + ip_start: list = [int(a) for a in start.split('.')] + ip_end: list = [int(b) for b in end.split('.')] ips = zip(ip_start, ip_end) - ips_range = [0, 0, 0, 0] + ips_range: list = [0, 0, 0, 0] for ip_id, ip in enumerate(ips): calc_ip_range(ip, ip_id, ips_range) @@ -55,7 +55,7 @@ def calc_result(ips_range) -> int: :param ips_range: :return: int """ - result = 1 + result: int = 1 for i in ips_range: if i != 0: result *= i diff --git a/kyu_5/count_ip_addresses/test_ips_between.py b/kyu_5/count_ip_addresses/test_ips_between.py index 7eb4cd1095a..8460b7e1773 100644 --- a/kyu_5/count_ip_addresses/test_ips_between.py +++ b/kyu_5/count_ip_addresses/test_ips_between.py @@ -23,8 +23,9 @@ @allure.tag('ALGORITHMS', 'PARSING', 'STRINGS') -@allure.link(url='https://www.codewars.com/kata/526989a41034285187000de4/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/526989a41034285187000de4', + name='Source/Kata') @pytest.mark.skip(reason="The solution is not ready") # pylint: enable-msg=R0801 class IpsBetweenTestCase(unittest.TestCase): @@ -60,7 +61,7 @@ def test_ips_between(self): "of strings. The last address will always be greater " "than the first one.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ("10.0.0.0", "10.0.0.50", 50), ("20.0.0.10", "20.0.1.0", 246), ("10.0.0.0", "10.0.1.0", 256), @@ -69,8 +70,7 @@ def test_ips_between(self): ("180.0.0.0", "181.0.0.0", 16777216), ("1.2.3.4", "5.6.7.8", 67372036), ("180.0.0.0", "181.0.0.0", 16777216), - ("117.170.96.190", "117.172.196.242", 156724) - ] + ("117.170.96.190", "117.172.196.242", 156724)) for start, end, expected in test_data: result = ips_between(start, end) @@ -79,6 +79,7 @@ def test_ips_between(self): f"end: {end}) and verify " f"the output ({result}) " f"vs expected ({expected})"): + print_log(start=start, end=end, result=result, diff --git a/kyu_5/did_i_finish_my_sudoku/README.md b/kyu_5/did_i_finish_my_sudoku/README.md index bac1a6d3016..82b875903bc 100644 --- a/kyu_5/did_i_finish_my_sudoku/README.md +++ b/kyu_5/did_i_finish_my_sudoku/README.md @@ -56,4 +56,4 @@ Valid board example: For those who don't know the game, here are some information about rules and how to play [Sudoku](http://en.wikipedia.org/wiki/Sudoku) and [here.](http://www.sudokuessentials.com/) -[Source](https://www.codewars.com/kata/53db96041f1a7d32dc0004d2/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/53db96041f1a7d32dc0004d2) \ No newline at end of file diff --git a/kyu_5/did_i_finish_my_sudoku/is_sudoku_done.py b/kyu_5/did_i_finish_my_sudoku/is_sudoku_done.py index 894cebd6894..b69153bef7a 100644 --- a/kyu_5/did_i_finish_my_sudoku/is_sudoku_done.py +++ b/kyu_5/did_i_finish_my_sudoku/is_sudoku_done.py @@ -4,9 +4,12 @@ GitHub: https://github.com/ikostan """ -from kyu_5.did_i_finish_my_sudoku.sudoku_by_row import assert_sudoku_by_row -from kyu_5.did_i_finish_my_sudoku.sudoku_by_column import assert_sudoku_by_column -from kyu_5.did_i_finish_my_sudoku.sudoku_by_regions import assert_sudoku_by_region +from kyu_5.did_i_finish_my_sudoku.sudoku_by_row \ + import assert_sudoku_by_row +from kyu_5.did_i_finish_my_sudoku.sudoku_by_column \ + import assert_sudoku_by_column +from kyu_5.did_i_finish_my_sudoku.sudoku_by_regions \ + import assert_sudoku_by_region def done_or_not(board: list) -> str: diff --git a/kyu_5/did_i_finish_my_sudoku/sudoku_by_regions.py b/kyu_5/did_i_finish_my_sudoku/sudoku_by_regions.py index 6e5ded3e10a..9e4f6b28260 100644 --- a/kyu_5/did_i_finish_my_sudoku/sudoku_by_regions.py +++ b/kyu_5/did_i_finish_my_sudoku/sudoku_by_regions.py @@ -14,9 +14,9 @@ def assert_sudoku_by_region(board: list) -> bool: :param board: Sudoku list :return: boolean value (is Sudoku done or not) """ - row_length = len(board[0]) + row_length: int = len(board[0]) + step: int = 0 - step = 0 for i in gen_primes(): if row_length % i == 0: step = i diff --git a/kyu_5/did_i_finish_my_sudoku/test_did_i_finish_sudoku.py b/kyu_5/did_i_finish_my_sudoku/test_did_i_finish_sudoku.py index 1c4b137f310..41a277c72a4 100644 --- a/kyu_5/did_i_finish_my_sudoku/test_did_i_finish_sudoku.py +++ b/kyu_5/did_i_finish_my_sudoku/test_did_i_finish_sudoku.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.did_i_finish_my_sudoku.is_sudoku_done import done_or_not +from kyu_5.did_i_finish_my_sudoku.is_sudoku_done \ + import done_or_not # pylint: disable=R0801 @@ -30,7 +31,7 @@ 'MATHEMATICS', 'ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/53db96041f1a7d32dc0004d2/train/python', + url='https://www.codewars.com/kata/53db96041f1a7d32dc0004d2', name='Source/Kata') # pylint: enable=R0801 class DidIFinishedSudokuTestCase(unittest.TestCase): @@ -91,7 +92,7 @@ def test_done_or_not(self): 'Try again!')) # pylint: enable-msg=R0801 for board, expected in test_data: - result = done_or_not(board) + result: str = done_or_not(board) with allure.step("Enter sudoku and verify the output."): print_log(expected=expected, result=result) diff --git a/kyu_5/diophantine_equation/README.md b/kyu_5/diophantine_equation/README.md index bad8f364c0b..f618dfa91fc 100644 --- a/kyu_5/diophantine_equation/README.md +++ b/kyu_5/diophantine_equation/README.md @@ -33,4 +33,4 @@ solEquaStr(90002) --> "[]" x2 - 4 * y2 = (x - 2*y) * (x + 2*y) ``` -[Source](https://www.codewars.com/kata/554f76dca89983cc400000bb/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/554f76dca89983cc400000bb) \ No newline at end of file diff --git a/kyu_5/diophantine_equation/solution.py b/kyu_5/diophantine_equation/solution.py index cd6a3486400..28da02f352d 100644 --- a/kyu_5/diophantine_equation/solution.py +++ b/kyu_5/diophantine_equation/solution.py @@ -10,7 +10,7 @@ def sol_equa(n: int) -> list: Finds all integers x, y (x >= 0, y >= 0) solutions of a diophantine equation of the form x2 - 4 * y2 = n """ - result = [] + result: list = [] start = n//2 if n % 2 != 0: diff --git a/kyu_5/diophantine_equation/test_solution.py b/kyu_5/diophantine_equation/test_solution.py index 308b0c89064..28814cfc4f4 100644 --- a/kyu_5/diophantine_equation/test_solution.py +++ b/kyu_5/diophantine_equation/test_solution.py @@ -22,13 +22,15 @@ 'MATHEMATICS', 'ALGORITHMS', 'NUMBERS') -@allure.link(url='https://www.codewars.com/kata/554f76dca89983cc400000bb/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/554f76dca89983cc400000bb', + name='Source/Kata') @pytest.mark.skip(reason="The solution is not ready") class SolutionTestCase(unittest.TestCase): """ Testing sol_equa function """ + def test_solution_basic(self): """ Testing using basic test data diff --git a/kyu_5/directions_reduction/README.md b/kyu_5/directions_reduction/README.md index f7e3f9038f7..4620ef7078e 100644 --- a/kyu_5/directions_reduction/README.md +++ b/kyu_5/directions_reduction/README.md @@ -84,4 +84,4 @@ of strings with the needless directions removed (W<->E or S<->N side by side). the result path is itself : `["NORTH", "WEST", "SOUTH", "EAST"]`. * if you want to translate, please ask before translating. -[Source](https://www.codewars.com/kata/550f22f4d758534c1100025a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/550f22f4d758534c1100025a) \ No newline at end of file diff --git a/kyu_5/directions_reduction/directions_reduction.py b/kyu_5/directions_reduction/directions_reduction.py index 3022f1ee774..eac39edb5eb 100644 --- a/kyu_5/directions_reduction/directions_reduction.py +++ b/kyu_5/directions_reduction/directions_reduction.py @@ -8,8 +8,7 @@ "NORTH": "SOUTH", "SOUTH": "NORTH", "EAST": "WEST", - "WEST": "EAST", -} + "WEST": "EAST"} def dir_reduc(arr: list) -> list: diff --git a/kyu_5/directions_reduction/test_directions_reduction.py b/kyu_5/directions_reduction/test_directions_reduction.py index 9da89886bec..c3b0a953129 100644 --- a/kyu_5/directions_reduction/test_directions_reduction.py +++ b/kyu_5/directions_reduction/test_directions_reduction.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.directions_reduction.directions_reduction import dir_reduc +from kyu_5.directions_reduction.directions_reduction \ + import dir_reduc # pylint: disable-msg=R0801 @@ -20,8 +21,9 @@ @allure.feature("Lists") @allure.story('Directions Reduction') @allure.tag('FUNDAMENTALS') -@allure.link(url='https://www.codewars.com/kata/550f22f4d758534c1100025a/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/550f22f4d758534c1100025a', + name='Source/Kata') # pylint: enable-msg=R0801 class DirectionsReductionTestCase(unittest.TestCase): """ @@ -56,7 +58,7 @@ def test_directions_reduction(self): "strings and returns an array of strings with the needless " "directions removed (W<->E or S<->N side by side).

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"], ['WEST']), (["NORTH", "WEST", "SOUTH", "EAST"], @@ -72,8 +74,7 @@ def test_directions_reduction(self): 'WEST', 'NORTH', 'WEST', 'SOUTH', 'SOUTH']), (['WEST', 'NORTH', 'EAST', 'EAST', 'EAST', 'EAST', 'WEST', 'WEST', 'WEST', 'WEST', 'NORTH', 'NORTH', 'SOUTH', 'EAST'], - ['WEST', 'NORTH', 'NORTH', 'EAST']) - ) + ['WEST', 'NORTH', 'NORTH', 'EAST'])) for d in test_data: test_array = d[0].copy() diff --git a/kyu_5/extract_the_domain_name_from_url/README.md b/kyu_5/extract_the_domain_name_from_url/README.md index aea69e068ad..b45c8b35430 100644 --- a/kyu_5/extract_the_domain_name_from_url/README.md +++ b/kyu_5/extract_the_domain_name_from_url/README.md @@ -9,4 +9,4 @@ domain_name("http://www.zombie-bites.com") == "zombie-bites" domain_name("https://www.cnet.com") == "cnet" ``` -[Source](https://www.codewars.com/kata/514a024011ea4fb54200004b/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/514a024011ea4fb54200004b) \ No newline at end of file diff --git a/kyu_5/extract_the_domain_name_from_url/test_domain_name.py b/kyu_5/extract_the_domain_name_from_url/test_domain_name.py index 41b726c1eba..8b5058b0bff 100644 --- a/kyu_5/extract_the_domain_name_from_url/test_domain_name.py +++ b/kyu_5/extract_the_domain_name_from_url/test_domain_name.py @@ -11,7 +11,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.extract_the_domain_name_from_url.extract_domain_from_url import domain_name +from kyu_5.extract_the_domain_name_from_url.extract_domain_from_url \ + import domain_name # pylint: disable-msg=R0801 @@ -28,8 +29,9 @@ 'REGULAR EXPRESSIONS', 'DECLARATIVE PROGRAMMING', 'ADVANCED LANGUAGE FEATURES') -@allure.link(url='https://www.codewars.com/kata/514a024011ea4fb54200004b/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/514a024011ea4fb54200004b', + name='Source/Kata') # pylint: enable-msg=R0801 class DomainNameTestCase(unittest.TestCase): """ @@ -53,12 +55,11 @@ def test_domain_name(self): "

Assert that 'domain_name' function " "returns domain name from given URL string.

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("http://google.com", "google"), ("http://google.co.jp", "google"), ("www.xakep.ru", "xakep"), - ("https://youtube.com", "youtube"), - ) + ("https://youtube.com", "youtube")) for url, expected in test_data: with allure.step("Enter test string and verify the output"): diff --git a/kyu_5/factorial_decomposition/README.md b/kyu_5/factorial_decomposition/README.md index 5f918502551..c85ff0b2149 100644 --- a/kyu_5/factorial_decomposition/README.md +++ b/kyu_5/factorial_decomposition/README.md @@ -27,4 +27,4 @@ Notes to contain any redundant trailing whitespace: you can use dynamically allocated character strings. -[Source](https://www.codewars.com/kata/5a045fee46d843effa000070/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5a045fee46d843effa000070) \ No newline at end of file diff --git a/kyu_5/fibonacci_streaming/README.md b/kyu_5/fibonacci_streaming/README.md index 0ca7dc1a84a..f7b3b839e07 100644 --- a/kyu_5/fibonacci_streaming/README.md +++ b/kyu_5/fibonacci_streaming/README.md @@ -11,4 +11,4 @@ of the two previous elements. See: > 1, 1, 2, 3, 5, 8, 13, ..., 89, 144, 233, 377, ... ``` -[Source](https://www.codewars.com/kata/55695bc4f75bbaea5100016b/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/55695bc4f75bbaea5100016b) \ No newline at end of file diff --git a/kyu_5/fibonacci_streaming/all_fibonacci_numbers.py b/kyu_5/fibonacci_streaming/all_fibonacci_numbers.py index a9a777ab5b6..6c0eae593d4 100644 --- a/kyu_5/fibonacci_streaming/all_fibonacci_numbers.py +++ b/kyu_5/fibonacci_streaming/all_fibonacci_numbers.py @@ -12,8 +12,8 @@ def all_fibonacci_numbers(): contains all the numbers in a fibonacci sequence. :return: int """ - a = 0 - b = 1 + a: int = 0 + b: int = 1 yield 1 while True: diff --git a/kyu_5/fibonacci_streaming/test_all_fibonacci_numbers.py b/kyu_5/fibonacci_streaming/test_all_fibonacci_numbers.py index 70ad7243f29..7e238d4faa1 100644 --- a/kyu_5/fibonacci_streaming/test_all_fibonacci_numbers.py +++ b/kyu_5/fibonacci_streaming/test_all_fibonacci_numbers.py @@ -10,7 +10,8 @@ import itertools import allure from utils.log_func import print_log -from kyu_5.fibonacci_streaming.all_fibonacci_numbers import all_fibonacci_numbers +from kyu_5.fibonacci_streaming.all_fibonacci_numbers \ + import all_fibonacci_numbers # pylint: disable-msg=R0801 @@ -21,8 +22,9 @@ @allure.feature("Lists") @allure.story('Fibonacci Streaming') @allure.tag('ALGORITHMS') -@allure.link(url='https://www.codewars.com/kata/55695bc4f75bbaea5100016b/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/55695bc4f75bbaea5100016b', + name='Source/Kata') # pylint: enable-msg=R0801 class AllFibonacciNumbersTestCase(unittest.TestCase): """ @@ -56,10 +58,10 @@ def test_all_fibonacci_numbers(self): # pylint: enable-msg=R0801 with allure.step("Run all_fibonacci_numbers function" " and verify the result"): - expected = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, - 233, 377, 610, 987, 1597, 2584, 4181, 6765, - 10946, 17711, 28657, 46368, 75025, 121393, - 196418, 317811, 514229, 832040] + expected: list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, + 233, 377, 610, 987, 1597, 2584, 4181, 6765, + 10946, 17711, 28657, 46368, 75025, 121393, + 196418, 317811, 514229, 832040] result = list(itertools.islice(all_fibonacci_numbers(), 30)) diff --git a/kyu_5/find_the_safest_places_in_town/README.md b/kyu_5/find_the_safest_places_in_town/README.md index a395b2438a7..641871ba2fe 100644 --- a/kyu_5/find_the_safest_places_in_town/README.md +++ b/kyu_5/find_the_safest_places_in_town/README.md @@ -55,4 +55,4 @@ There are `200` random tests with `n <= 50`. Inefficient solutions might time ou This kata is inspired by [ThoughtWorks' coding challenge.](https://github.com/Fun-Coding-Challenges/ada-lovelace-coding-challenge) -[Source](https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed) \ No newline at end of file diff --git a/kyu_5/find_the_safest_places_in_town/print_agents.py b/kyu_5/find_the_safest_places_in_town/print_agents.py index b6598f92eef..261598d0315 100644 --- a/kyu_5/find_the_safest_places_in_town/print_agents.py +++ b/kyu_5/find_the_safest_places_in_town/print_agents.py @@ -17,9 +17,9 @@ def print_map(agents: list, digit: int, expected: list) -> None: :param expected: expected results :return: """ - empty = ' |' - agent = '-|' - longest = '+|' + empty: str = ' |' + agent: str = '-|' + longest: str = '+|' for col in range(0, digit): temp = "|" diff --git a/kyu_5/find_the_safest_places_in_town/test_advice.py b/kyu_5/find_the_safest_places_in_town/test_advice.py index 612d381e20e..df59a21feee 100644 --- a/kyu_5/find_the_safest_places_in_town/test_advice.py +++ b/kyu_5/find_the_safest_places_in_town/test_advice.py @@ -9,8 +9,10 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.find_the_safest_places_in_town.advice import advice, create_city_map, agents_cleanup -from kyu_5.find_the_safest_places_in_town.print_agents import print_map +from kyu_5.find_the_safest_places_in_town.advice \ + import advice, create_city_map, agents_cleanup +from kyu_5.find_the_safest_places_in_town.print_agents \ + import print_map # pylint: disable-msg=R0801 @@ -21,8 +23,9 @@ @allure.feature("Lists") @allure.story('Find the safest places in town') @allure.tag('ALGORITHMS') -@allure.link(url='https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5dd82b7cd3d6c100109cb4ed', + name='Source/Kata') # pylint: enable-msg=R0801 class FirstAdviceTestCase(unittest.TestCase): """ @@ -49,18 +52,17 @@ def test_create_city_map(self): "

The function should generate city map with coordinates.

") # pylint: enable-msg=R0801 with allure.step("Enter test data and verify the output"): - test_data = [ + test_data: tuple = ( (2, {(0, 0), (0, 1), (1, 0), (1, 1)}), (0, set()), (3, {(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), - (1, 2), (2, 0), (2, 1), (2, 2)}), - ] + (1, 2), (2, 0), (2, 1), (2, 2)})) for data in test_data: # test data - n = data[0] - expected = data[1] - actual = create_city_map(n) + n: int = data[0] + expected: set = data[1] + actual: set = create_city_map(n) # test log print_log(n=n, expected=expected, actual=actual) # assertion @@ -88,7 +90,7 @@ def test_agents_cleanup(self): "outside of the city boundaries.

") # pylint: enable-msg=R0801 with allure.step("Enter test data and verify the output"): - test_data = [ + test_data: tuple = ( ({(0, 0), (1, 5), (5, 1)}, 6, {(0, 0), (1, 5), (5, 1)}), ({(0, 0), (1, 1), (99, 99)}, 2, {(0, 0), (1, 1)}), ({(22, 23), (56, 35), (15, 7), (40, 15), (36, 30), (52, 47), @@ -96,15 +98,14 @@ def test_agents_cleanup(self): (2, 30), (58, 40), (60, 36), (2, 67), (16, 58), (53, 13), (36, 38), (29, 54), (50, 15), (14, 28), (23, 30), (0, 64), (58, 57), (38, 2), (28, 40), (22, 6), - (12, 46), (50, 35), (56, 27)}, 10, set()), - ] + (12, 46), (50, 35), (56, 27)}, 10, set())) for data in test_data: # test data - agents = data[0] - n = data[1] - expected = data[2] - actual = agents_cleanup(agents, n) + agents: set = data[0] + n: int = data[1] + expected: set = data[2] + actual: set = agents_cleanup(agents, n) # test log print_log(agents=agents, n=n, expected=expected, actual=actual) # assertion @@ -134,7 +135,7 @@ def test_first_non_repeating_letter(self): "agents.

") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ([(1, 1)], 2, [(0, 0)], "Should return top left corner for agent in the bottom right"), ([(1, 1)], 0, [], @@ -488,7 +489,7 @@ def test_first_non_repeating_letter(self): (66, 49), (39, 11), (12, 26), (7, 21), (58, 47), (5, 52), (29, 19), (1, 20), (62, 44), (54, 38), (25, 19), (8, 36), (41, 53), (3, 57), (8, 61), (40, 22), (63, 36), (0, 11), (23, 53), (47, 44), (22, 7), (5, 56), (10, 64), (4, 12), (5, 48), (34, 11), (38, 5), (37, 27), (54, 67), (36, 54), - (22, 54)], 47, [(46, 38)], 'Big lists')] + (22, 54)], 47, [(46, 38)], 'Big lists')) # pylint: enable-msg=C0301 for data in test_data: # test data diff --git a/kyu_5/find_the_smallest/README.md b/kyu_5/find_the_smallest/README.md index c15e9f6ea4b..f31e8bb4555 100644 --- a/kyu_5/find_the_smallest/README.md +++ b/kyu_5/find_the_smallest/README.md @@ -44,4 +44,4 @@ smallest(1000000) --> [1, 0, 6] or ... Have a look at "Sample Tests" to see the input and output in each language -[Source](https://www.codewars.com/kata/573992c724fc289553000e95/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/573992c724fc289553000e95) \ No newline at end of file diff --git a/kyu_5/find_the_smallest/test_smallest.py b/kyu_5/find_the_smallest/test_smallest.py index d6b5950f83e..8aeb9a42501 100644 --- a/kyu_5/find_the_smallest/test_smallest.py +++ b/kyu_5/find_the_smallest/test_smallest.py @@ -21,8 +21,9 @@ @allure.feature("Lists") @allure.story('Find the smallest') @allure.tag('FUNDAMENTALS') -@allure.link(url='https://www.codewars.com/kata/573992c724fc289553000e95/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/573992c724fc289553000e95', + name='Source/Kata') @pytest.mark.skip(reason="The solution is not ready") # pylint: enable-msg=R0801 class FindSmallestTestCase(unittest.TestCase): @@ -46,20 +47,20 @@ def test_smallest(self): '

Test Description:

' "

") # pylint: enable-msg=R0801 - test_data = ((261235, [126235, 2, 0]), - (209917, [29917, 0, 1]), - (285365, [238565, 3, 1]), - (269045, [26945, 3, 0]), - (296837, [239687, 4, 1]), - (346674147588841927, [134667414758884927, 14, 0]), - (352343279580894007, [35234327958089407, 15, 0]), - (633814808310045545, [63381480831045545, 11, 0]), - (935855753, [358557539, 0, 8]), - (71269954474326234, [12679954474326234, 0, 3]), - (400360725952391834, [3460725952391834, 0, 3]), - (914459749498173781, [144597494981737819, 0, 17]), - (113343536213382181, [111334353621338218, 17, 0]), - (614132919143656569, [141326919143656569, 0, 5])) + test_data: tuple = ((261235, [126235, 2, 0]), + (209917, [29917, 0, 1]), + (285365, [238565, 3, 1]), + (269045, [26945, 3, 0]), + (296837, [239687, 4, 1]), + (346674147588841927, [134667414758884927, 14, 0]), + (352343279580894007, [35234327958089407, 15, 0]), + (633814808310045545, [63381480831045545, 11, 0]), + (935855753, [358557539, 0, 8]), + (71269954474326234, [12679954474326234, 0, 3]), + (400360725952391834, [3460725952391834, 0, 3]), + (914459749498173781, [144597494981737819, 0, 17]), + (113343536213382181, [111334353621338218, 17, 0]), + (614132919143656569, [141326919143656569, 0, 5])) for n, expected in test_data: result = smallest(n) diff --git a/kyu_5/first_non_repeating_character/README.md b/kyu_5/first_non_repeating_character/README.md index a8e357bc031..c5351e29ddc 100644 --- a/kyu_5/first_non_repeating_character/README.md +++ b/kyu_5/first_non_repeating_character/README.md @@ -13,4 +13,4 @@ For example, the input 'sTreSS' should return 'T'. If a string contains all repeating characters, it should return an empty string ("") or None -- see sample tests. -[Source](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e) \ No newline at end of file diff --git a/kyu_5/first_non_repeating_character/first_non_repeating_letter.py b/kyu_5/first_non_repeating_character/first_non_repeating_letter.py index 3607a94ccc4..ed031c912af 100644 --- a/kyu_5/first_non_repeating_character/first_non_repeating_letter.py +++ b/kyu_5/first_non_repeating_character/first_non_repeating_letter.py @@ -14,7 +14,7 @@ def first_non_repeating_letter(string: str) -> str: :return: str """ result: str = '' - string_lower = string.lower() + string_lower: str = string.lower() for i, s in enumerate(string_lower): if string_lower.count(s) == 1: diff --git a/kyu_5/first_non_repeating_character/test_first_non_repeating_letter.py b/kyu_5/first_non_repeating_character/test_first_non_repeating_letter.py index 9bc6ee9b31f..ffafcf755cd 100644 --- a/kyu_5/first_non_repeating_character/test_first_non_repeating_letter.py +++ b/kyu_5/first_non_repeating_character/test_first_non_repeating_letter.py @@ -24,8 +24,9 @@ @allure.tag('ALGORITHMS', 'STRINGS', 'SEARCH') -@allure.link(url='https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52bc74d4ac05d0945d00054e', + name='Source/Kata') # pylint: enable-msg=R0801 class FirstNonRepeatingLetterTestCase(unittest.TestCase): """ @@ -62,7 +63,7 @@ def test_first_non_repeating_letter(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ('a', 'a'), ('stress', 't'), ('moonmen', 'e'), @@ -72,8 +73,7 @@ def test_first_non_repeating_letter(self): ('~><#~><', '#'), ('hello world, eh?', 'w'), ('sTreSS', 'T'), - ('Go hang a salami, I\'m a lasagna hog!', ',') - ] + ('Go hang a salami, I\'m a lasagna hog!', ',')) for data in test_data: string = data[0] diff --git a/kyu_5/flatten/README.md b/kyu_5/flatten/README.md index 9e111b11302..53c4d1dc538 100644 --- a/kyu_5/flatten/README.md +++ b/kyu_5/flatten/README.md @@ -16,4 +16,4 @@ flatten('a', ['b', 2], 3, None, [[4], ['c']]) # returns ['a', 'b', 2, 3, None, 4 ``` -[Source](https://www.codewars.com/kata/513fa1d75e4297ba38000003/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/513fa1d75e4297ba38000003) \ No newline at end of file diff --git a/kyu_5/flatten/test_flatten.py b/kyu_5/flatten/test_flatten.py index beca243af17..3334bcc9dff 100644 --- a/kyu_5/flatten/test_flatten.py +++ b/kyu_5/flatten/test_flatten.py @@ -21,8 +21,9 @@ @allure.story('flatten()') @allure.tag('ALGORITHMS', 'ARRAYS') -@allure.link(url='https://www.codewars.com/kata/513fa1d75e4297ba38000003/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/513fa1d75e4297ba38000003', + name='Source/Kata') # pylint: enable-msg=R0801 class FlattenTestCase(unittest.TestCase): """ @@ -58,7 +59,7 @@ def test_flatten(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test data #1 and verify the output"): - expected = [] + expected: list = [] print_log(args=None, expected=expected) self.assertListEqual(expected, diff --git a/kyu_5/human_readable_time/README.md b/kyu_5/human_readable_time/README.md index 8b45bb94adc..cf71746e3cb 100644 --- a/kyu_5/human_readable_time/README.md +++ b/kyu_5/human_readable_time/README.md @@ -11,4 +11,4 @@ The maximum time never exceeds `359999 (99:59:59)` You can find some examples in the test fixtures. -[Source](https://www.codewars.com/kata/52685f7382004e774f0001f7/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52685f7382004e774f0001f7) \ No newline at end of file diff --git a/kyu_5/human_readable_time/make_readable.py b/kyu_5/human_readable_time/make_readable.py index 6cb1faa990e..1812c999cb4 100644 --- a/kyu_5/human_readable_time/make_readable.py +++ b/kyu_5/human_readable_time/make_readable.py @@ -41,8 +41,8 @@ def time_converter(time: int) -> str: if time == 0: time_str: str = '00' elif len(str(time)) > 1: - time_str: str = str(time) + time_str = str(time) else: - time_str: str = '0' + str(time) + time_str = '0' + str(time) return time_str diff --git a/kyu_5/human_readable_time/test_make_readable.py b/kyu_5/human_readable_time/test_make_readable.py index 279e3c40cf2..7f3d442dc89 100644 --- a/kyu_5/human_readable_time/test_make_readable.py +++ b/kyu_5/human_readable_time/test_make_readable.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.human_readable_time.make_readable import make_readable +from kyu_5.human_readable_time.make_readable \ + import make_readable # pylint: disable-msg=R0801 @@ -23,8 +24,9 @@ 'DATES/TIME', 'MATHEMATICS', 'NUMBERS') -@allure.link(url='https://www.codewars.com/kata/52685f7382004e774f0001f7/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52685f7382004e774f0001f7', + name='Source/Kata') # pylint: enable-msg=R0801 class MakeReadableTestCase(unittest.TestCase): """ @@ -57,13 +59,12 @@ def test_make_readable(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test number and verify the output"): - data = [ + data: tuple = ( (0, "00:00:00"), (5, "00:00:05"), (60, "00:01:00"), (86399, "23:59:59"), - (359999, "99:59:59"), - ] + (359999, "99:59:59")) for seconds, expected in data: print_log(seconds=seconds, expected=expected) diff --git a/kyu_5/integers_recreation_one/README.md b/kyu_5/integers_recreation_one/README.md index c4719ccddcc..59e0d713bea 100644 --- a/kyu_5/integers_recreation_one/README.md +++ b/kyu_5/integers_recreation_one/README.md @@ -18,4 +18,4 @@ list_squared(1, 250) --> [[1, 1], [42, 2500], [246, 84100]] list_squared(42, 250) --> [[42, 2500], [246, 84100]] ``` -[Source](https://www.codewars.com/kata/55aa075506463dac6600010d/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/55aa075506463dac6600010d) \ No newline at end of file diff --git a/kyu_5/integers_recreation_one/solution.py b/kyu_5/integers_recreation_one/solution.py index 6512455a1eb..10ade26a10b 100644 --- a/kyu_5/integers_recreation_one/solution.py +++ b/kyu_5/integers_recreation_one/solution.py @@ -16,7 +16,7 @@ def divisor_generator(digit: int): # You should only be running your loop from 1 to the # square root of n. Then to find the pair, do n / i, # and this will cover the whole problem space. - large_divisors = [] + large_divisors: list = [] for i in range(1, int(math.sqrt(digit) + 1)): if digit % i == 0: large_divisors.append(i) diff --git a/kyu_5/integers_recreation_one/test_list_squared.py b/kyu_5/integers_recreation_one/test_list_squared.py index befc5bfb180..d8b25f20734 100644 --- a/kyu_5/integers_recreation_one/test_list_squared.py +++ b/kyu_5/integers_recreation_one/test_list_squared.py @@ -22,8 +22,9 @@ 'ARRAYS', 'FUNDAMENTALS', 'OPTIMIZATION') -@allure.link(url='https://www.codewars.com/kata/55aa075506463dac6600010d/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/55aa075506463dac6600010d', + name='Source/Kata') class ListSquaredTestCase(unittest.TestCase): """ Integers: Recreation One @@ -60,7 +61,7 @@ def test_flatten(self): "all integers between m and n whose sum of squared divisors " "is itself a square.

") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (1, 250, [[1, 1], [42, 2500], [246, 84100]]), (42, 250, @@ -76,8 +77,7 @@ def test_flatten(self): [4264, 24304900]]), (257, 4195, [[287, 84100], [728, 722500], [1434, 2856100], [1673, 2856100], - [1880, 4884100]]) - ) + [1880, 4884100]])) for m, n, expected in test_data: with allure.step("Enter test data and verify the output..."): diff --git a/kyu_5/josephus_survivor/README.md b/kyu_5/josephus_survivor/README.md index f1f5149cee8..4040612a810 100644 --- a/kyu_5/josephus_survivor/README.md +++ b/kyu_5/josephus_survivor/README.md @@ -27,4 +27,4 @@ be helpful, but as much larger numbers will be used, using an array/list to compute the number of the survivor may be too slow; you may assume that both n and k will always be >=1. -[Source](https://www.codewars.com/kata/555624b601231dc7a400017a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/555624b601231dc7a400017a) \ No newline at end of file diff --git a/kyu_5/josephus_survivor/test_josephus_survivor.py b/kyu_5/josephus_survivor/test_josephus_survivor.py index cae7bdbaa5a..e388be09aa8 100644 --- a/kyu_5/josephus_survivor/test_josephus_survivor.py +++ b/kyu_5/josephus_survivor/test_josephus_survivor.py @@ -10,7 +10,8 @@ import pytest import allure from utils.log_func import print_log -from kyu_5.josephus_survivor.josephus_survivor import josephus_survivor +from kyu_5.josephus_survivor.josephus_survivor \ + import josephus_survivor @allure.epic('5 kyu') @@ -25,8 +26,9 @@ 'LISTS', 'DATA STRUCTURES', 'ARRAYS') -@allure.link(url='https://www.codewars.com/kata/555624b601231dc7a400017a/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/555624b601231dc7a400017a', + name='Source/Kata') @pytest.mark.skip(reason="The solution is not ready") class JosephusSurvivorTestCase(unittest.TestCase): """ @@ -52,13 +54,12 @@ def test_josephus_survivor(self): "correctly returns who is the \"survivor\", ie: the " "last element of a Josephus permutation.

") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ((7, 3), 4), ((11, 19), 10), ((1, 300), 1), ((14, 2), 13), - ((100, 1), 100) - ] + ((100, 1), 100)) for test_data, expected in test_data: total = test_data[0] diff --git a/kyu_5/master_your_primes_sieve_with_memoization/primes.py b/kyu_5/master_your_primes_sieve_with_memoization/primes.py index 71a42922971..889902b2720 100644 --- a/kyu_5/master_your_primes_sieve_with_memoization/primes.py +++ b/kyu_5/master_your_primes_sieve_with_memoization/primes.py @@ -15,7 +15,7 @@ def is_prime(digit: int) -> bool: :param digit: int :return: bool """ - primes = [2, 3, 5, 7] + primes: list = [2, 3, 5, 7] if digit < 2: return False diff --git a/kyu_5/master_your_primes_sieve_with_memoization/test_primes.py b/kyu_5/master_your_primes_sieve_with_memoization/test_primes.py index 66130e801fd..7ca27daa299 100644 --- a/kyu_5/master_your_primes_sieve_with_memoization/test_primes.py +++ b/kyu_5/master_your_primes_sieve_with_memoization/test_primes.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.master_your_primes_sieve_with_memoization.primes import is_prime +from kyu_5.master_your_primes_sieve_with_memoization.primes \ + import is_prime @allure.epic('5 kyu') @@ -24,8 +25,9 @@ 'DESIGN PATTERNS', 'DESIGN PRINCIPLES', 'OPTIMIZATION') -@allure.link(url='https://www.codewars.com/kata/58603c898989d15e9e000475', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/58603c898989d15e9e000475', + name='Source/Kata') class PrimesTestCase(unittest.TestCase): """ Testing is_prime function @@ -52,7 +54,7 @@ def test_primes(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test number and verify the output"): - test_data = [ + test_data: tuple = ( (1, False), (2, True), (5, True), @@ -72,8 +74,7 @@ def test_primes(self): (17, True), (19, True), (23, True), - (29, True), - ] + (29, True)) for data in test_data: number = data[0] diff --git a/kyu_5/moving_zeros_to_the_end/README.md b/kyu_5/moving_zeros_to_the_end/README.md index aae25d7b179..93d5eed492c 100644 --- a/kyu_5/moving_zeros_to_the_end/README.md +++ b/kyu_5/moving_zeros_to_the_end/README.md @@ -7,4 +7,4 @@ end, preserving the order of the other elements. move_zeros([false,1,0,1,2,0,1,3,"a"]) # returns[false,1,1,2,1,3,"a",0,0] ``` -[Source](https://www.codewars.com/kata/52597aa56021e91c93000cb0/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52597aa56021e91c93000cb0) \ No newline at end of file diff --git a/kyu_5/moving_zeros_to_the_end/test_move_zeros.py b/kyu_5/moving_zeros_to_the_end/test_move_zeros.py index 639e29ebc33..6952978478e 100644 --- a/kyu_5/moving_zeros_to_the_end/test_move_zeros.py +++ b/kyu_5/moving_zeros_to_the_end/test_move_zeros.py @@ -23,8 +23,9 @@ 'INTERVIEW QUESTIONS', 'ARRAYS', 'SORTING') -@allure.link(url='', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52597aa56021e91c93000cb0', + name='Source/Kata') # pylint: enable-msg=R0801 class MoveZerosTestCase(unittest.TestCase): """ @@ -48,7 +49,7 @@ def test_move_zeros(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test data (list) and verify the output"): - test_data = [ + test_data: tuple = ( ([1, 2, 0, 1, 0, 1, 0, 3, 0, 1], [1, 2, 1, 1, 3, 1, 0, 0, 0, 0]), ([9, 0.0, 0, 9, 1, 2, 0, 1, 0, 1, 0.0, 3, 0, 1, 9, 0, 0, 0, 0, 9], [9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), @@ -64,11 +65,10 @@ def test_move_zeros(self): ([0, 0], [0, 0]), ([0], [0]), ([False], [False]), - ([], []), - ] + ([], [])) for d in test_data: - array = d[0] - expected = d[1] + array: list = d[0] + expected: list = d[1] print_log(array=array, expected=expected) self.assertEqual(expected, move_zeros(array)) diff --git a/kyu_5/multidimensional_neighbourhood/README.md b/kyu_5/multidimensional_neighbourhood/README.md index 670ff164b8a..c7a5554a355 100644 --- a/kyu_5/multidimensional_neighbourhood/README.md +++ b/kyu_5/multidimensional_neighbourhood/README.md @@ -40,4 +40,4 @@ Your code should be performant. * Matrix is empty * Distance equals 0 -[Source](https://www.codewars.com/kata/5b47ba689c9a7591e70001a3/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5b47ba689c9a7591e70001a3) \ No newline at end of file diff --git a/kyu_5/not_very_secure/README.md b/kyu_5/not_very_secure/README.md index cb23460e9f2..017595b4b17 100644 --- a/kyu_5/not_very_secure/README.md +++ b/kyu_5/not_very_secure/README.md @@ -10,4 +10,4 @@ The string has the following conditions to be alphanumeric: `0` to `9` * No whitespaces / underscore -[Source](https://www.codewars.com/kata/526dbd6c8c0eb53254000110/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/526dbd6c8c0eb53254000110) \ No newline at end of file diff --git a/kyu_5/not_very_secure/test_alphanumeric.py b/kyu_5/not_very_secure/test_alphanumeric.py index 40dc93af3a6..c05cf5e81b5 100644 --- a/kyu_5/not_very_secure/test_alphanumeric.py +++ b/kyu_5/not_very_secure/test_alphanumeric.py @@ -26,8 +26,9 @@ 'ADVANCED LANGUAGE FEATURES', 'FUNDAMENTALS', 'STRINGS') -@allure.link(url='https://www.codewars.com/kata/526dbd6c8c0eb53254000110/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/526dbd6c8c0eb53254000110', + name='Source/Kata') # pylint: enable-msg=R0801 class AlphanumericTestCase(unittest.TestCase): """ @@ -60,11 +61,10 @@ def test_alphanumeric(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ("hello world_", False), ("PassW0rd", True), - (" ", False) - ] + (" ", False)) for password, expected in test_data: print_log(password=password, diff --git a/kyu_5/number_of_trailing_zeros_of_n/README.md b/kyu_5/number_of_trailing_zeros_of_n/README.md index 63ec7134a34..a98bba13c4a 100644 --- a/kyu_5/number_of_trailing_zeros_of_n/README.md +++ b/kyu_5/number_of_trailing_zeros_of_n/README.md @@ -22,4 +22,4 @@ zeros(12) = 2 Hint: You're not meant to calculate the factorial. Find another way to find the number of zeros. -[Source](https://www.codewars.com/kata/52f787eb172a8b4ae1000a34/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52f787eb172a8b4ae1000a34) \ No newline at end of file diff --git a/kyu_5/number_of_trailing_zeros_of_n/test_zeros.py b/kyu_5/number_of_trailing_zeros_of_n/test_zeros.py index 48573964f5f..8497849d22a 100644 --- a/kyu_5/number_of_trailing_zeros_of_n/test_zeros.py +++ b/kyu_5/number_of_trailing_zeros_of_n/test_zeros.py @@ -22,8 +22,9 @@ @allure.tag('ALGORITHMS', 'MATHEMATICS', 'NUMBERS') -@allure.link(url='https://www.codewars.com/kata/52f787eb172a8b4ae1000a34/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52f787eb172a8b4ae1000a34', + name='Source/Kata') # pylint: enable-msg=R0801 class ZerosTestCase(unittest.TestCase): """ @@ -47,18 +48,18 @@ def test_zeros(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test number and verify the result"): - test_data = [ + test_data: tuple = ( (0, 0, "Testing with n = 0"), (6, 1, "Testing with n = 6"), (10, 2, "Testing with n = 10"), (12, 2, "Testing with n = 12"), - (30, 7, "Testing with n = 30"), - ] + (30, 7, "Testing with n = 30")) for data in test_data: - number = data[0] - expected = data[1] - message = data[2] + + number: int = data[0] + expected: int = data[1] + message: str = data[2] print_log(message=message, number=number, diff --git a/kyu_5/number_of_trailing_zeros_of_n/zeros.py b/kyu_5/number_of_trailing_zeros_of_n/zeros.py index 71b69e12c86..b80999fcce6 100644 --- a/kyu_5/number_of_trailing_zeros_of_n/zeros.py +++ b/kyu_5/number_of_trailing_zeros_of_n/zeros.py @@ -29,11 +29,10 @@ def zeros(n) -> int: :param n: int :return: int """ - # Initialize result - count = 0 + count: int = 0 + i: int = 5 - i = 5 while (n / i) >= 1: # update Count count += int(n / i) diff --git a/kyu_5/simple_pig_latin/README.md b/kyu_5/simple_pig_latin/README.md index 3a2427e69ce..9b2914930b1 100644 --- a/kyu_5/simple_pig_latin/README.md +++ b/kyu_5/simple_pig_latin/README.md @@ -10,4 +10,4 @@ the end of the word. Leave punctuation marks untouched. > pig_it('Hello world !') # elloHay orldway ! ``` -[Source](https://www.codewars.com/kata/520b9d2ad5c005041100000f/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/520b9d2ad5c005041100000f) \ No newline at end of file diff --git a/kyu_5/simple_pig_latin/test_pig_it.py b/kyu_5/simple_pig_latin/test_pig_it.py index c2174495f28..deac617144c 100644 --- a/kyu_5/simple_pig_latin/test_pig_it.py +++ b/kyu_5/simple_pig_latin/test_pig_it.py @@ -20,8 +20,9 @@ @allure.feature("String") @allure.story('Simple Pig Latin') @allure.tag('ALGORITHMS') -@allure.link(url='https://www.codewars.com/kata/520b9d2ad5c005041100000f/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/520b9d2ad5c005041100000f', + name='Source/Kata') # pylint: enable-msg=R0801 class PigItTestCase(unittest.TestCase): """ @@ -48,12 +49,11 @@ def test_pig_it(self): "

") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ('Pig latin is cool', 'igPay atinlay siay oolcay'), ('This is my string', 'hisTay siay ymay tringsay'), ('Hello world !', 'elloHay orldway !'), - ("O tempora o mores !", 'Oay emporatay oay oresmay !') - ] + ("O tempora o mores !", 'Oay emporatay oay oresmay !')) for text, expected in test_data: print_log(expected=expected, text=text) diff --git a/kyu_5/sports_league_table_ranking/README.md b/kyu_5/sports_league_table_ranking/README.md index a764cc8cff9..2edc0698c59 100644 --- a/kyu_5/sports_league_table_ranking/README.md +++ b/kyu_5/sports_league_table_ranking/README.md @@ -64,4 +64,4 @@ better scoring differential, it ranks better than Team 3. All values of Team In this example you have to return the array `[4, 4, 6, 3, 1, 2].` -[Source](https://www.codewars.com/kata/5e0baea9d772160032022e8c/train/python) +[Source](https://www.codewars.com/kata/5e0baea9d772160032022e8c) diff --git a/kyu_5/sports_league_table_ranking/compute_ranks.py b/kyu_5/sports_league_table_ranking/compute_ranks.py index f22108fc70f..c33e9351f07 100644 --- a/kyu_5/sports_league_table_ranking/compute_ranks.py +++ b/kyu_5/sports_league_table_ranking/compute_ranks.py @@ -25,7 +25,6 @@ def compute_ranks(number: int, games: list) -> list: :param games: list :return: list """ - if not games: return [1] * number @@ -51,7 +50,6 @@ def process_not_played_games(teams: dict, number: int) -> None: :param number: :return: """ - for num in range(number): if num not in teams: check_if_team_registered(num, teams, number) @@ -91,9 +89,8 @@ def check_if_team_registered(team, teams, number) -> None: :param number: :return: """ - if team not in teams: - teams[team]: dict = {} + teams[team] = {} teams[team]["GD"] = 0 teams[team]["For:Against"] = [0, 0] teams[team]["Points"] = 0 @@ -110,7 +107,6 @@ def calc_team_points(team, teams, score_a, score_b) -> None: :param score_b: :return: """ - if score_a > score_b: teams[team]['Points'] += 2 elif score_a == score_b: @@ -127,7 +123,6 @@ def calc_for_against(teams, team, team_1, team_2) -> None: :param team_2: :return: """ - teams[team]["For:Against"][0] += team_1 teams[team]["For:Against"][1] += team_2 @@ -139,9 +134,9 @@ def calc_gd(teams) -> None: :param teams: :return: """ - for team in teams: - teams[team]["GD"] = teams[team]["For:Against"][0] - teams[team]["For:Against"][1] + teams[team]["GD"] = ( + teams[team]["For:Against"][0] - teams[team]["For:Against"][1]) def calc_rank(teams: dict) -> None: @@ -156,7 +151,6 @@ def calc_rank(teams: dict) -> None: :param teams: :return: """ - for team_a in teams: for team_b in teams: if team_a != team_b: diff --git a/kyu_5/sports_league_table_ranking/test_compute_ranks.py b/kyu_5/sports_league_table_ranking/test_compute_ranks.py index 138a93400a3..0a250a5b6f5 100644 --- a/kyu_5/sports_league_table_ranking/test_compute_ranks.py +++ b/kyu_5/sports_league_table_ranking/test_compute_ranks.py @@ -7,7 +7,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.sports_league_table_ranking.compute_ranks import compute_ranks +from kyu_5.sports_league_table_ranking.compute_ranks \ + import compute_ranks @allure.epic('5 kyu') @@ -20,8 +21,9 @@ 'FUNDAMENTALS', 'ARRAYS', 'SORTING') -@allure.link(url='https://www.codewars.com/kata/5e0baea9d772160032022e8c/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5e0baea9d772160032022e8c', + name='Source/Kata') class ComputeRanksTestCase(unittest.TestCase): """ Testing Sports League Table Ranking @@ -64,7 +66,7 @@ def test_compute_ranks(self): "scored and those conceded)" "
  • - Goals scored
  • ") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (6, [[0, 5, 2, 2], [1, 4, 0, 2], @@ -95,14 +97,13 @@ def test_compute_ranks(self): [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), (8, [[0, 7, 2, 0]], - [1, 2, 2, 2, 2, 2, 2, 8]) - ] + [1, 2, 2, 2, 2, 2, 2, 8])) for data in test_data: - number = data[0] - games = data[1] - expected = data[2] - actual_result = compute_ranks(number, games) + number: int = data[0] + games: list = data[1] + expected: list = data[2] + actual_result: list = compute_ranks(number, games) print_log(number=number, games=games, expected=expected, diff --git a/kyu_5/string_incrementer/README.md b/kyu_5/string_incrementer/README.md index a28c163d740..2ddad59bc82 100644 --- a/kyu_5/string_incrementer/README.md +++ b/kyu_5/string_incrementer/README.md @@ -22,4 +22,4 @@ foo099 -> foo100 *Attention:* If the number has leading zeros the amount of digits should be considered. -[Source](https://www.codewars.com/kata/54a91a4883a7de5d7800009c/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/54a91a4883a7de5d7800009c) \ No newline at end of file diff --git a/kyu_5/string_incrementer/test_increment_string.py b/kyu_5/string_incrementer/test_increment_string.py index 04a100fdd3a..4df13b12675 100644 --- a/kyu_5/string_incrementer/test_increment_string.py +++ b/kyu_5/string_incrementer/test_increment_string.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.string_incrementer.string_incrementer import increment_string +from kyu_5.string_incrementer.string_incrementer \ + import increment_string # pylint: disable-msg=R0801 @@ -26,8 +27,9 @@ 'ADVANCED LANGUAGE FEATURES', 'STRINGS PARSING', 'ALGORITHMS') -@allure.link(url='https://www.codewars.com/kata/54a91a4883a7de5d7800009c/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/54a91a4883a7de5d7800009c', + name='Source/Kata') # pylint: enable-msg=R0801 class StringIncrementerTestCase(unittest.TestCase): """ @@ -54,7 +56,7 @@ def test_increment_string(self): "should be appended to the new string." "

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("foo", "foo1"), ("foobar001", "foobar002"), ("foobar1", "foobar2"), @@ -63,8 +65,7 @@ def test_increment_string(self): ("foobar099", "foobar100"), ("", "1"), ('009', '010'), - ('^0000007', '^0000008') - ) + ('^0000007', '^0000008')) for sting, expected in test_data: with allure.step("Enter test string and verify the output"): diff --git a/kyu_5/sum_of_pairs/README.md b/kyu_5/sum_of_pairs/README.md index f65dab040c3..7a7176839cf 100644 --- a/kyu_5/sum_of_pairs/README.md +++ b/kyu_5/sum_of_pairs/README.md @@ -30,4 +30,6 @@ sum_pairs([10, 5, 2, 3, 7, 5], 10) Negative numbers and duplicate numbers can and will appear. NOTE: There will also be lists tested of lengths upwards of 10,000,000 -elements. Be sure your code doesn't time out. \ No newline at end of file +elements. Be sure your code doesn't time out. + +[Source](https://www.codewars.com/kata/54d81488b981293527000c8f) \ No newline at end of file diff --git a/kyu_5/sum_of_pairs/test_sum_pairs.py b/kyu_5/sum_of_pairs/test_sum_pairs.py index 8a1a908df01..a4342e55e26 100644 --- a/kyu_5/sum_of_pairs/test_sum_pairs.py +++ b/kyu_5/sum_of_pairs/test_sum_pairs.py @@ -25,8 +25,9 @@ 'MEMOIZATION', 'DESIGN PATTERNS', 'DESIGN PRINCIPLES') -@allure.link(url='https://www.codewars.com/kata/54d81488b981293527000c8f/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/54d81488b981293527000c8f', + name='Source/Kata') class SumPairsTestCase(unittest.TestCase): """ Testing 'sum_pairs' function @@ -54,7 +55,7 @@ def test_sum_pairs(self): "from the left please) in order of appearance that add up " "to form the sum.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([1, 4, 8, 7, 3, 15], 8, [1, 7], "should return [1, 7] for sum = 8"), ([1, -2, 3, 0, -6, 1], -6, [0, -6], @@ -70,8 +71,7 @@ def test_sum_pairs(self): ([0, 2, 0], 0, [0, 0], "should return [0, 0] for sum = 0"), ([5, 9, 13, -3], 10, [13, -3], - "should return [13, -3] for sum = 10"), - ) + "should return [13, -3] for sum = 10")) with allure.step("Enter a test list and verify the output."): for ints, s, expected, message in test_data: diff --git a/kyu_5/the_hashtag_generator/README.md b/kyu_5/the_hashtag_generator/README.md index 1caf5fde485..234f53a4851 100644 --- a/kyu_5/the_hashtag_generator/README.md +++ b/kyu_5/the_hashtag_generator/README.md @@ -19,4 +19,4 @@ Here's the deal: "" => false ``` -[Source](https://www.codewars.com/kata/52449b062fb80683ec000024/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/52449b062fb80683ec000024) \ No newline at end of file diff --git a/kyu_5/the_hashtag_generator/hashtag_generator.py b/kyu_5/the_hashtag_generator/hashtag_generator.py index 5138d2e73bb..7c6eb5b94eb 100644 --- a/kyu_5/the_hashtag_generator/hashtag_generator.py +++ b/kyu_5/the_hashtag_generator/hashtag_generator.py @@ -5,7 +5,7 @@ """ -def generate_hashtag(word: str) -> (bool, str): +def generate_hashtag(word: str) -> bool | str: """ The Hashtag Generator. diff --git a/kyu_5/the_hashtag_generator/test_generate_hashtag.py b/kyu_5/the_hashtag_generator/test_generate_hashtag.py index 221ad24c747..d0810759423 100644 --- a/kyu_5/the_hashtag_generator/test_generate_hashtag.py +++ b/kyu_5/the_hashtag_generator/test_generate_hashtag.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_5.the_hashtag_generator.hashtag_generator import generate_hashtag +from kyu_5.the_hashtag_generator.hashtag_generator \ + import generate_hashtag # pylint: disable-msg=R0801 @@ -21,8 +22,9 @@ @allure.story('The Hashtag Generator') @allure.tag('ALGORITHMS', 'SORTING') -@allure.link(url='https://www.codewars.com/kata/52449b062fb80683ec000024/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52449b062fb80683ec000024', + name='Source/Kata') # pylint: enable-msg=R0801 class GenerateHashtagTestCase(unittest.TestCase): """ @@ -33,7 +35,6 @@ def test_generate_hashtag(self): """ Testing 'generate_hashtag' function """ - allure.dynamic.title("Testing 'generate_hashtag' function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( @@ -53,7 +54,7 @@ def test_generate_hashtag(self): "must return false." "

    ") - test_data = ( + test_data: tuple = ( ('', False, 'Expected an empty string to return False'), @@ -87,8 +88,7 @@ def test_generate_hashtag(self): 'oooooong Cat', False, 'Should return False if the final word is ' - 'longer than 140 chars.'), - ) + 'longer than 140 chars.')) for string, expected, message in test_data: actual_result = generate_hashtag(string) diff --git a/kyu_5/tic_tac_toe_checker/README.md b/kyu_5/tic_tac_toe_checker/README.md index afd56a8f6a0..105c4c70ac5 100644 --- a/kyu_5/tic_tac_toe_checker/README.md +++ b/kyu_5/tic_tac_toe_checker/README.md @@ -24,4 +24,4 @@ We want our function to return: You may assume that the board passed in is valid in the context of a game of Tic-Tac-Toe. -[Source](https://www.codewars.com/kata/525caa5c1bf619d28c000335/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/525caa5c1bf619d28c000335) \ No newline at end of file diff --git a/kyu_5/tic_tac_toe_checker/checker.py b/kyu_5/tic_tac_toe_checker/checker.py index 7dc285549de..2eb2b662203 100644 --- a/kyu_5/tic_tac_toe_checker/checker.py +++ b/kyu_5/tic_tac_toe_checker/checker.py @@ -5,7 +5,7 @@ """ -def is_solved(board): +def is_solved(board) -> int: """ Checks whether the board's current state is solved: -1 if the board is not yet finished (there are empty spots), @@ -35,14 +35,14 @@ def is_solved(board): return 0 -def check_diagonals(board): +def check_diagonals(board) -> int | None: """ Check board by diagonal :param board: list :return: 1, 2, or None """ - i = 0 - temp = set() + i: int = 0 + temp: set = set() for row in board: temp.add(row[i]) i += 1 @@ -62,7 +62,7 @@ def check_diagonals(board): return None -def check_cols(board): +def check_cols(board) -> int | None: """ Check board by column :param board: list @@ -79,7 +79,7 @@ def check_cols(board): return None -def check_rows(board: list): +def check_rows(board: list) -> int | None: """ Check board by row :param board: list diff --git a/kyu_5/tic_tac_toe_checker/test_checker.py b/kyu_5/tic_tac_toe_checker/test_checker.py index f570292f57f..bbb7386ce88 100644 --- a/kyu_5/tic_tac_toe_checker/test_checker.py +++ b/kyu_5/tic_tac_toe_checker/test_checker.py @@ -20,8 +20,9 @@ @allure.story('Tic-Tac-Toe Checker') @allure.tag('ALGORITHMS', 'ARRAY') -@allure.link(url='https://www.codewars.com/kata/525caa5c1bf619d28c000335/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/525caa5c1bf619d28c000335', + name='Source/Kata') class IsSolvedTestCase(unittest.TestCase): """ Testing is_solved function @@ -52,7 +53,7 @@ def test_is_solved(self): "

    The function should return whether the board's " "current state is solved.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([[0, 0, 1], [0, 1, 2], [2, 1, 0]], -1, 'not yet finished'), @@ -67,12 +68,10 @@ def test_is_solved(self): [1, 2, 1]], 0, 'draw'), ([[1, 2, 0], [0, 1, 2], - [0, 0, 1]], 1, 'wining diagonal' - ) - ) + [0, 0, 1]], 1, 'wining diagonal')) for board, expected, message in test_data: - result = is_solved(board) + result: int = is_solved(board) with allure.step("Enter Tic-Tac-Toe board and verify the output."): print_log(expected=expected, result=result, message=message) self.assertEqual(expected, result, msg=message) diff --git a/kyu_5/valid_parentheses/README.md b/kyu_5/valid_parentheses/README.md index cf21fd00bd6..6f34fd70b4e 100644 --- a/kyu_5/valid_parentheses/README.md +++ b/kyu_5/valid_parentheses/README.md @@ -27,4 +27,4 @@ valid ASCII characters. Furthermore, the input string may be empty and/or not contain any parentheses at all. Do not treat other forms of brackets as parentheses (e.g. `[]`, `{}`, `<>`). -[Source](https://www.codewars.com/kata/52774a314c2333f0a7000688/train/python) +[Source](https://www.codewars.com/kata/52774a314c2333f0a7000688) diff --git a/kyu_5/valid_parentheses/test_valid_parentheses.py b/kyu_5/valid_parentheses/test_valid_parentheses.py index afb5bf688f0..335b041f4f9 100644 --- a/kyu_5/valid_parentheses/test_valid_parentheses.py +++ b/kyu_5/valid_parentheses/test_valid_parentheses.py @@ -8,7 +8,8 @@ import unittest import allure -from kyu_5.valid_parentheses.valid_parentheses import valid_parentheses +from kyu_5.valid_parentheses.valid_parentheses \ + import valid_parentheses from utils.log_func import print_log @@ -21,8 +22,9 @@ @allure.tag('ALGORITHMS', 'VALIDATION', 'UTILITIES') -@allure.link(url='https://www.codewars.com/kata/52774a314c2333f0a7000688/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/52774a314c2333f0a7000688', + name='Source/Kata') class ValidParenthesesTestCase(unittest.TestCase): """ Testing valid_parentheses function @@ -54,7 +56,7 @@ def test_valid_parentheses(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( (" (", False), (")test", False), ("", True), @@ -63,8 +65,7 @@ def test_valid_parentheses(self): ("()", True), (")(()))", False), ("(", False), - ("(())((()())())", True), - ] + ("(())((()())())", True)) for string, expected in test_data: print_log(string=string, diff --git a/kyu_5/valid_parentheses/valid_parentheses.py b/kyu_5/valid_parentheses/valid_parentheses.py index 81a0c3076e0..68b68b325ec 100644 --- a/kyu_5/valid_parentheses/valid_parentheses.py +++ b/kyu_5/valid_parentheses/valid_parentheses.py @@ -15,7 +15,7 @@ def valid_parentheses(string: str) -> bool: :return: bool """ - string: str = clean_up_string(string) + string = clean_up_string(string) if string == "" or not string: return True diff --git a/kyu_5/where_my_anagrams_at/README.md b/kyu_5/where_my_anagrams_at/README.md index fbee7205176..7da7d1da4cb 100644 --- a/kyu_5/where_my_anagrams_at/README.md +++ b/kyu_5/where_my_anagrams_at/README.md @@ -23,4 +23,4 @@ anagrams('laser', ['lazing', 'lazy', 'lacer']) => [] ``` -[Source](https://www.codewars.com/kata/523a86aa4230ebb5420001e1/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/523a86aa4230ebb5420001e1) \ No newline at end of file diff --git a/kyu_5/where_my_anagrams_at/test_anagrams.py b/kyu_5/where_my_anagrams_at/test_anagrams.py index ef88ea558de..537b6139778 100644 --- a/kyu_5/where_my_anagrams_at/test_anagrams.py +++ b/kyu_5/where_my_anagrams_at/test_anagrams.py @@ -22,7 +22,7 @@ @allure.tag('ALGORITHMS', 'STRINGS') @allure.link( - url='https://www.codewars.com/kata/523a86aa4230ebb5420001e1/train/python', + url='https://www.codewars.com/kata/523a86aa4230ebb5420001e1', name='Source/Kata') # pylint: enable=R0801 class AnagramsTestCase(unittest.TestCase): @@ -49,18 +49,17 @@ def test_anagrams(self): # pylint: enable=R0801 with allure.step("Enter test data (list of strings)" " and verify the output"): - test_data = [ + test_data: tuple = ( ('abba', ['aabb', 'abcd', 'bbaa', 'dada'], ['aabb', 'bbaa']), ('racer', ['crazer', 'carer', 'racar', 'caers', 'racer'], - ['carer', 'racer']) - ] + ['carer', 'racer'])) for d in test_data: - string = d[0] - array = d[1] - expected = d[2] + string: str = d[0] + array: list = d[1] + expected: list = d[2] print_log(array=array, expected=expected) self.assertListEqual(expected, anagrams(string, array)) diff --git a/kyu_6/README.md b/kyu_6/README.md index 6c0dad3e0f7..effac3ed330 100644 --- a/kyu_6/README.md +++ b/kyu_6/README.md @@ -15,44 +15,44 @@ rank - the harder the kata the faster you advance. ### List of Completed Kata (Python 3) -| No. | Puzzle/Kata Name | Solution / GitHub Link | -|-----|:--------------------------------------------------------------------------------------------------------------------------:|---------------------------------------------------------------------------------------------------:| -|1 |[Character frequency](https://www.codewars.com/kata/53e895e28f9e66a56900011a/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/character_frequency) | -|2 |[Count letters in string](https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/count_letters_in_string) | -|3 |[Duplicate Encoder](https://www.codewars.com/kata/54b42f9314d9229fd6000d9c/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/duplicate_encoder) | -|4 |[Find the odd int](https://www.codewars.com/kata/54da5a58ea159efa38000836/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/find_the_odd_int) | -|5 |[First character that repeats](https://www.codewars.com/kata/54f9f4d7c41722304e000bbb/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/first_character_that_repeats) | -|6 |[Character with longest consecutive repetition](https://www.codewars.com/kata/586d6cefbcc21eed7a001155/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/longest_repetition) | -|7 |[Numericals of a String](https://www.codewars.com/kata/5b4070144d7d8bbfe7000001/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/numericals_of_string) | -|8 |[Permute a Palindrome](https://www.codewars.com/kata/58ae6ae22c3aaafc58000079/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/permute_a_palindrome) | -|9 |[Pyramid Array](https://www.codewars.com/kata/515f51d438015969f7000013/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/pyramid_array) | -|10 |[String subpattern recognition I](https://www.codewars.com/kata/5a49f074b3bfa89b4c00002b/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_1) | -|11 |[String subpattern recognition II](https://www.codewars.com/kata/5a4a391ad8e145cdee0000c4/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_2) | -|12 |[String subpattern recognition III](https://www.codewars.com/kata/5a4a2973d8e14586c700000a/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_3) | -|13 |[String transformer](https://www.codewars.com/kata/5878520d52628a092f0002d0/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_transformer) | -|14 |[Unique In Order](https://www.codewars.com/kata/54e6533c92449cc251001667/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/unique_in_order) | -|15 |[Vasya - Clerk](https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/vasya_clerk) | -|16 |[Multiples of 3 or 5](https://www.codewars.com/kata/514b92a657cdc65150000006/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/multiples_of_3_or_5) | -|17 |[Sum of Digits / Digital Root](https://www.codewars.com/kata/541c8630095125aba6000c00/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/sum_of_digits_digital_root) | -|18 |[Binary to Text (ASCII) Conversion](https://www.codewars.com/kata/5583d268479559400d000064/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/binary_to_text_ascii_conversion) | -|19 |[Casino chips](https://www.codewars.com/kata/5e0b72d2d772160011133654/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/casino_chips) | -|20 |[Pokemon Damage Calculator](https://www.codewars.com/kata/536e9a7973130a06eb000e9f/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/pokemon_damage_calculator) | -|21 |[Help the bookseller !](https://www.codewars.com/kata/54dc6f5a224c26032800005c/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/help_the_bookseller) | -|22 |[Row of the odd triangle](https://www.codewars.com/kata/5d5a7525207a674b71aa25b5/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/row_of_the_odd_triangle) | -|23 |[Disease Spread](https://www.codewars.com/kata/566543703c72200f0b0000c9) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/disease_spread) | -|24 |[A Rule of Divisibility by 13](https://www.codewars.com/kata/564057bc348c7200bd0000ff/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/a_rule_of_divisibility_by_13) | -|25 |[Color Choice](https://www.codewars.com/kata/55be10de92aad5ef28000023/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/color_choice) | -|26 |[DefaultList](https://www.codewars.com/kata/5e882048999e6c0023412908/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/default_list) | -|27 |[Easy Diagonal](https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/easy_diagonal) | -|28 |[Array to HTML table](https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/array_to_html_table) | -|29 |[rotate the letters of each element](https://www.codewars.com/kata/5e98712b7de14f0026ef1cc1/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/rotate_the_letters_of_each_element)| -|30 |[Number Zoo Patrol](https://www.codewars.com/kata/5276c18121e20900c0000235/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/number_zoo_patrol) | -|31 |[Your order, please](https://www.codewars.com/kata/55c45be3b2079eccff00010f) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/your_order_please) | -|32 |[Who likes it?](https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/who_likes_it) | -|33 |[Encrypt this!](https://www.codewars.com/kata/5848565e273af816fb000449) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/encrypt_this) | -|34 |[Decipher this!](https://www.codewars.com/kata/decipher-this) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/decipher_this) | -|35 |[Format a string of names like 'Bart, Lisa & Maggie'.](https://www.codewars.com/kata/53368a47e38700bd8300030d/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/format_string_of_names) | -|36 |[Sort the odd](https://www.codewars.com/kata/578aa45ee9fd15ff4600090d/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/sort_the_odd) | -|37 |[Array.diff](https://www.codewars.com/kata/523f5d21c841566fde000009/train/python) |[Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/array_diff) | +| No. | Puzzle/Kata Name | Solution / GitHub Link | +|-----|:--------------------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------:| +| 1 | [Character frequency](https://www.codewars.com/kata/53e895e28f9e66a56900011a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/character_frequency) | +| 2 | [Count letters in string](https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/count_letters_in_string) | +| 3 | [Duplicate Encoder](https://www.codewars.com/kata/54b42f9314d9229fd6000d9c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/duplicate_encoder) | +| 4 | [Find the odd int](https://www.codewars.com/kata/54da5a58ea159efa38000836) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/find_the_odd_int) | +| 5 | [First character that repeats](https://www.codewars.com/kata/54f9f4d7c41722304e000bbb) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/first_character_that_repeats) | +| 6 | [Character with longest consecutive repetition](https://www.codewars.com/kata/586d6cefbcc21eed7a001155) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/longest_repetition) | +| 7 | [Numericals of a String](https://www.codewars.com/kata/5b4070144d7d8bbfe7000001) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/numericals_of_string) | +| 8 | [Permute a Palindrome](https://www.codewars.com/kata/58ae6ae22c3aaafc58000079) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/permute_a_palindrome) | +| 9 | [Pyramid Array](https://www.codewars.com/kata/515f51d438015969f7000013) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/pyramid_array) | +| 10 | [String subpattern recognition I](https://www.codewars.com/kata/5a49f074b3bfa89b4c00002b) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_1) | +| 11 | [String subpattern recognition II](https://www.codewars.com/kata/5a4a391ad8e145cdee0000c4) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_2) | +| 12 | [String subpattern recognition III](https://www.codewars.com/kata/5a4a2973d8e14586c700000a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_subpattern_recognition_3) | +| 13 | [String transformer](https://www.codewars.com/kata/5878520d52628a092f0002d0) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/string_transformer) | +| 14 | [Unique In Order](https://www.codewars.com/kata/54e6533c92449cc251001667) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/unique_in_order) | +| 15 | [Vasya - Clerk](https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/vasya_clerk) | +| 16 | [Multiples of 3 or 5](https://www.codewars.com/kata/514b92a657cdc65150000006) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/multiples_of_3_or_5) | +| 17 | [Sum of Digits / Digital Root](https://www.codewars.com/kata/541c8630095125aba6000c00) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/sum_of_digits_digital_root) | +| 18 | [Binary to Text (ASCII) Conversion](https://www.codewars.com/kata/5583d268479559400d000064) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/binary_to_text_ascii_conversion) | +| 19 | [Casino chips](https://www.codewars.com/kata/5e0b72d2d772160011133654) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/casino_chips) | +| 20 | [Pokemon Damage Calculator](https://www.codewars.com/kata/536e9a7973130a06eb000e9f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/pokemon_damage_calculator) | +| 21 | [Help the bookseller !](https://www.codewars.com/kata/54dc6f5a224c26032800005c) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/help_the_bookseller) | +| 22 | [Row of the odd triangle](https://www.codewars.com/kata/5d5a7525207a674b71aa25b5) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/row_of_the_odd_triangle) | +| 23 | [Disease Spread](https://www.codewars.com/kata/566543703c72200f0b0000c9) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/disease_spread) | +| 24 | [A Rule of Divisibility by 13](https://www.codewars.com/kata/564057bc348c7200bd0000ff) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/a_rule_of_divisibility_by_13) | +| 25 | [Color Choice](https://www.codewars.com/kata/55be10de92aad5ef28000023) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/color_choice) | +| 26 | [DefaultList](https://www.codewars.com/kata/5e882048999e6c0023412908) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/default_list) | +| 27 | [Easy Diagonal](https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/easy_diagonal) | +| 28 | [Array to HTML table](https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/array_to_html_table) | +| 29 | [rotate the letters of each element](https://www.codewars.com/kata/5e98712b7de14f0026ef1cc1) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/rotate_the_letters_of_each_element) | +| 30 | [Number Zoo Patrol](https://www.codewars.com/kata/5276c18121e20900c0000235) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/number_zoo_patrol) | +| 31 | [Your order, please](https://www.codewars.com/kata/55c45be3b2079eccff00010f) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/your_order_please) | +| 32 | [Who likes it?](https://www.codewars.com/kata/5266876b8f4bf2da9b000362) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/who_likes_it) | +| 33 | [Encrypt this!](https://www.codewars.com/kata/5848565e273af816fb000449) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/encrypt_this) | +| 34 | [Decipher this!](https://www.codewars.com/kata/decipher-this) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/decipher_this) | +| 35 | [Format a string of names like 'Bart, Lisa & Maggie'.](https://www.codewars.com/kata/53368a47e38700bd8300030d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/format_string_of_names) | +| 36 | [Sort the odd](https://www.codewars.com/kata/578aa45ee9fd15ff4600090d) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/sort_the_odd) | +| 37 | [Array.diff](https://www.codewars.com/kata/523f5d21c841566fde000009) | [Solution](https://github.com/ikostan/codewars/tree/master/kyu_6/array_diff) | [Source](https://www.codewars.com/about) \ No newline at end of file diff --git a/kyu_6/a_rule_of_divisibility_by_13/README.md b/kyu_6/a_rule_of_divisibility_by_13/README.md index 13d7f51722e..6371c3374fb 100644 --- a/kyu_6/a_rule_of_divisibility_by_13/README.md +++ b/kyu_6/a_rule_of_divisibility_by_13/README.md @@ -35,4 +35,4 @@ on an integer `n (>=0)`. `thirt` will return the stationary number. `thirt(321)` calculates `48, 48` and returns `48`. -[Source](https://www.codewars.com/kata/564057bc348c7200bd0000ff/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/564057bc348c7200bd0000ff) \ No newline at end of file diff --git a/kyu_6/a_rule_of_divisibility_by_13/test_thirt.py b/kyu_6/a_rule_of_divisibility_by_13/test_thirt.py index 50e44568095..89444fb387d 100644 --- a/kyu_6/a_rule_of_divisibility_by_13/test_thirt.py +++ b/kyu_6/a_rule_of_divisibility_by_13/test_thirt.py @@ -19,8 +19,9 @@ @allure.feature("Math") @allure.story('A Rule of Divisibility by 13') @allure.tag('FUNDAMENTALS') -@allure.link(url='https://www.codewars.com/kata/564057bc348c7200bd0000ff/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/564057bc348c7200bd0000ff', + name='Source/Kata') class ThirtTestCase(unittest.TestCase): """ Testing 'thirt' function @@ -43,7 +44,7 @@ def test_thirt(self): "on an integer n (>=0). 'thirt' should return the stationary" " number.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (1234567, 87), (321, 48), (8529, 79), @@ -58,6 +59,7 @@ def test_thirt(self): with allure.step(f"Enter a n ({n}) and verify the " f"expected output ({expected}) vs " f"actual result ({actual_result})"): + print_log(n=n, expected=expected, result=actual_result) diff --git a/kyu_6/a_rule_of_divisibility_by_13/thirt.py b/kyu_6/a_rule_of_divisibility_by_13/thirt.py index eaa29a262f9..c94eef2fa9c 100644 --- a/kyu_6/a_rule_of_divisibility_by_13/thirt.py +++ b/kyu_6/a_rule_of_divisibility_by_13/thirt.py @@ -4,7 +4,7 @@ GitHub: https://github.com/ikostan """ -REMAINDERS = (1, 10, 9, 12, 3, 4) +REMAINDERS: tuple = (1, 10, 9, 12, 3, 4) def thirt(n: int) -> int: diff --git a/kyu_6/array_diff/README.md b/kyu_6/array_diff/README.md index b50f6f502bc..8caddce6786 100644 --- a/kyu_6/array_diff/README.md +++ b/kyu_6/array_diff/README.md @@ -16,4 +16,4 @@ from the other: array_diff([1,2,2,2,3],[2]) == [1,3] ``` -[Source](https://www.codewars.com/kata/523f5d21c841566fde000009/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/523f5d21c841566fde000009) \ No newline at end of file diff --git a/kyu_6/array_diff/test_array_diff.py b/kyu_6/array_diff/test_array_diff.py index 32992307d2b..ee99d51e5f9 100644 --- a/kyu_6/array_diff/test_array_diff.py +++ b/kyu_6/array_diff/test_array_diff.py @@ -23,7 +23,7 @@ 'ARRAYS', 'LISTS') @allure.link( - url='https://www.codewars.com/kata/523f5d21c841566fde000009/train/python', + url='https://www.codewars.com/kata/523f5d21c841566fde000009', name='Source/Kata') # pylint: enable-msg=R0801 class ArrayDiffTestCase(unittest.TestCase): @@ -59,7 +59,7 @@ def test_array_diff_function(self): "and returns the result. It should remove all values from " "list a, which are present in list b.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([1, 2], [1], [2], "a was [1,2], b was [1], expected [2]"), ([1, 2, 2], [1], [2, 2], "a was [1,2,2], b was [1], expected [2,2]"), ([1, 2, 2], [2], [1], "a was [1,2,2], b was [2], expected [1]"), @@ -75,6 +75,7 @@ def test_array_diff_function(self): with allure.step("Enter a test data and verify the " "expected output vs actual result"): + print_log(a=a, b=b, exp=expected, diff --git a/kyu_6/array_to_html_table/README.md b/kyu_6/array_to_html_table/README.md index 483bc1f8adf..1fb0294b5c1 100644 --- a/kyu_6/array_to_html_table/README.md +++ b/kyu_6/array_to_html_table/README.md @@ -80,4 +80,4 @@ P.S.: I understand, that with larger inputs checking for mismatches in the expec and actual output can be cumbersome, but as of now I can hardly come up with something that would make this easier. Any ideas would be helpful! -[Source](https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a) \ No newline at end of file diff --git a/kyu_6/array_to_html_table/test_list_to_html_table.py b/kyu_6/array_to_html_table/test_list_to_html_table.py index d9a2edbefc0..8e19f268323 100644 --- a/kyu_6/array_to_html_table/test_list_to_html_table.py +++ b/kyu_6/array_to_html_table/test_list_to_html_table.py @@ -22,7 +22,7 @@ 'ARRAYS', 'LISTS') @allure.link( - url='https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a/train/python', + url='https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a', name='Source/Kata') class ArrayToTableTestCase(unittest.TestCase): """ @@ -46,7 +46,7 @@ def test_array_to_table_function(self): "(data, header, index) and returns a string " "containing HTML tags representing the table.

    ") # pylint: enable-msg=R0801 - test_data = ([ + test_data: tuple = ( { "input": ([["o"]]), "output": "" @@ -101,9 +101,7 @@ def test_array_to_table_function(self): "" "" "" - "
    TrueFalseFalseTrueTrue
    " - }, - ]) + ""}) for test_item in test_data: data: list = test_item["input"][0] diff --git a/kyu_6/binary_to_text_ascii_conversion/README.md b/kyu_6/binary_to_text_ascii_conversion/README.md index 441ea7773dd..c4e8dd455cc 100644 --- a/kyu_6/binary_to_text_ascii_conversion/README.md +++ b/kyu_6/binary_to_text_ascii_conversion/README.md @@ -12,4 +12,4 @@ Characters can be in the range from "00000000" to "11111111" (inclusive) Note: In the case of an empty binary string your function should return an empty string. -[Source](https://www.codewars.com/kata/5583d268479559400d000064/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5583d268479559400d000064) \ No newline at end of file diff --git a/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py b/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py index 2e25db6f5bf..0a7e205c80c 100644 --- a/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py +++ b/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.binary_to_text_ascii_conversion.binary_to_string import binary_to_string +from kyu_6.binary_to_text_ascii_conversion.binary_to_string \ + import binary_to_string @allure.epic('6 kyu') @@ -25,7 +26,7 @@ 'FORMATS', 'STRINGS') @allure.link( - url='https://www.codewars.com/kata/5583d268479559400d000064/train/python', + url='https://www.codewars.com/kata/5583d268479559400d000064', name='Source/Kata') class SequenceTestCase(unittest.TestCase): """ @@ -49,7 +50,7 @@ def test_binary_to_string(self): "

    Test a function that takes in a binary string and returns " "the equivalent decoded text (the text is ASCII encoded).

    ") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ('0100100001100101011011000110110001101111', 'Hello'), ('00110001001100000011000100110001', '1011'), ('010100110111000001100001011100100110101101' @@ -76,14 +77,14 @@ def test_binary_to_string(self): '(?>?<~~~~~)(*&%^98713/-/*-*/'), ('011001100111011101101111001100010110001101' '101110001101100110011001101010011100010110' - '010101110001', 'fwo1cn6fjqeq') - ] + '010101110001', 'fwo1cn6fjqeq')) for binary, expected in test_data: actual_result = binary_to_string(binary) with allure.step(f"Enter a binary ({binary}) and verify the " f"expected output ({expected}) vs " f"actual result ({actual_result})"): + print_log(binary=binary, expected=expected, result=actual_result) diff --git a/kyu_6/casino_chips/README.md b/kyu_6/casino_chips/README.md index d0a31765581..21a9cc0dca2 100644 --- a/kyu_6/casino_chips/README.md +++ b/kyu_6/casino_chips/README.md @@ -26,4 +26,4 @@ More examples in the test cases. Good luck! Brute force is not the way to go here. Look for a simplifying mathematical approach. -[Source](https://www.codewars.com/kata/5e0b72d2d772160011133654/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5e0b72d2d772160011133654) \ No newline at end of file diff --git a/kyu_6/casino_chips/solve.py b/kyu_6/casino_chips/solve.py index 80d89fe4227..10c397f214d 100644 --- a/kyu_6/casino_chips/solve.py +++ b/kyu_6/casino_chips/solve.py @@ -25,7 +25,7 @@ def solve(arr: list) -> int: :param arr: :return: """ - arr: list = sorted(arr) + arr = sorted(arr) if arr[0] + arr[1] <= arr[2]: return arr[0] + arr[1] diff --git a/kyu_6/casino_chips/test_solve.py b/kyu_6/casino_chips/test_solve.py index 8b23bdc16e5..af7b95b5934 100644 --- a/kyu_6/casino_chips/test_solve.py +++ b/kyu_6/casino_chips/test_solve.py @@ -24,7 +24,7 @@ 'ALGORITHMS', 'NUMBERS') @allure.link( - url='https://www.codewars.com/kata/5e0b72d2d772160011133654/train/python', + url='https://www.codewars.com/kata/5e0b72d2d772160011133654', name='Source/Kata') # pylint: enable-msg=R0801 class SolveTestCase(unittest.TestCase): @@ -49,7 +49,7 @@ def test_solve(self): "maximum number of days you can pick the chips. Each " "day you need to take exactly two chips.

    ") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( ([8, 8, 8], 12), ([1, 1, 1], 1), ([8, 1, 4], 5), @@ -62,7 +62,7 @@ def test_solve(self): ([4, 4, 3], 5), ([1, 2, 1], 2), ([4, 1, 1], 2), - ([8, 2, 8], 9),] + ([8, 2, 8], 9)) for arr, expected in test_data: actual_result = solve(arr) diff --git a/kyu_6/character_frequency/README.md b/kyu_6/character_frequency/README.md index 6fd328c74e2..050d9e9656d 100644 --- a/kyu_6/character_frequency/README.md +++ b/kyu_6/character_frequency/README.md @@ -19,4 +19,4 @@ will return Letter frequency analysis is often used to analyse simple substitution cipher texts like those created by the Caesar cipher. -[Source](https://www.codewars.com/kata/53e895e28f9e66a56900011a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/53e895e28f9e66a56900011a) \ No newline at end of file diff --git a/kyu_6/character_frequency/character_frequency.py b/kyu_6/character_frequency/character_frequency.py index 469405dc784..443bc4f6680 100644 --- a/kyu_6/character_frequency/character_frequency.py +++ b/kyu_6/character_frequency/character_frequency.py @@ -15,7 +15,7 @@ def letter_frequency(text: str) -> list: """ results: list = [] chars: dict = {} - text: str = text.lower() + text = text.lower() for c in text: if c.isalpha() and c not in chars: @@ -32,7 +32,6 @@ def sort_list(results: list) -> list: :param results: list :return: list """ - is_sorted: bool = False results_length: int = len(results) diff --git a/kyu_6/character_frequency/test_character_frequency.py b/kyu_6/character_frequency/test_character_frequency.py index 28854902b18..595bd263a52 100644 --- a/kyu_6/character_frequency/test_character_frequency.py +++ b/kyu_6/character_frequency/test_character_frequency.py @@ -9,7 +9,9 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.character_frequency.character_frequency import letter_frequency +from kyu_6.character_frequency.character_frequency \ + import letter_frequency + # pylint: disable-msg=R0801 @allure.epic('6 kyu') @@ -22,7 +24,7 @@ 'STRINGS', 'UTILITIES') @allure.link( - url='https://www.codewars.com/kata/53e895e28f9e66a56900011a/train/python', + url='https://www.codewars.com/kata/53e895e28f9e66a56900011a', name='Source/Kata') # pylint: enable-msg=R0801 class LetterFrequencyTestCase(unittest.TestCase): @@ -47,13 +49,11 @@ def test_letter_frequency_all_lower(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass a test string and verify the result"): - string = 'wklv lv d vhfuhw phvvdjh' - - result = letter_frequency(string) - - expected = [('v', 5), ('h', 4), ('d', 2), ('l', 2), - ('w', 2), ('f', 1), ('j', 1), ('k', 1), - ('p', 1), ('u', 1)] + string: str = 'wklv lv d vhfuhw phvvdjh' + result: list = letter_frequency(string) + expected: list = [('v', 5), ('h', 4), ('d', 2), ('l', 2), + ('w', 2), ('f', 1), ('j', 1), ('k', 1), + ('p', 1), ('u', 1)] print_log(string=string, expected=expected) self.assertEqual(expected, result) @@ -75,16 +75,14 @@ def test_letter_frequency_mixed(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass a test string and verify the result"): - string = "As long as I'm learning something, " \ - "I figure I'm OK - it's a decent day." - - result = letter_frequency(string) - - expected = [('i', 7), ('a', 5), ('e', 5), ('n', 5), - ('g', 4), ('s', 4), ('m', 3), ('o', 3), - ('t', 3), ('d', 2), ('l', 2), ('r', 2), - ('c', 1), ('f', 1), ('h', 1), ('k', 1), - ('u', 1), ('y', 1)] + string: str = "As long as I'm learning something, " \ + "I figure I'm OK - it's a decent day." + result: list = letter_frequency(string) + expected: list = [('i', 7), ('a', 5), ('e', 5), ('n', 5), + ('g', 4), ('s', 4), ('m', 3), ('o', 3), + ('t', 3), ('d', 2), ('l', 2), ('r', 2), + ('c', 1), ('f', 1), ('h', 1), ('k', 1), + ('u', 1), ('y', 1)] print_log(string=string, expected=expected) self.assertEqual(expected, result) @@ -106,17 +104,15 @@ def test_letter_frequency_all_caps(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass a test string and verify the result"): - string = 'IWT LDGAS XH HIXAA P LTXGS EAPRT, ' \ - 'STHEXIT BN TUUDGIH ID BPZT RATPG ' \ - 'PCS ETGUTRI HTCHT DU XI.' - - result = letter_frequency(string) - - expected = [('t', 12), ('i', 7), ('h', 6), ('a', 5), - ('g', 5), ('p', 5), ('x', 5), ('d', 4), - ('s', 4), ('u', 4), ('e', 3), ('r', 3), - ('b', 2), ('c', 2), ('l', 2), ('n', 1), - ('w', 1), ('z', 1)] + string: str = 'IWT LDGAS XH HIXAA P LTXGS EAPRT, ' \ + 'STHEXIT BN TUUDGIH ID BPZT RATPG ' \ + 'PCS ETGUTRI HTCHT DU XI.' + result: list = letter_frequency(string) + expected: list = [('t', 12), ('i', 7), ('h', 6), ('a', 5), + ('g', 5), ('p', 5), ('x', 5), ('d', 4), + ('s', 4), ('u', 4), ('e', 3), ('r', 3), + ('b', 2), ('c', 2), ('l', 2), ('n', 1), + ('w', 1), ('z', 1)] print_log(string=string, expected=expected) self.assertEqual(expected, result) diff --git a/kyu_6/color_choice/README.md b/kyu_6/color_choice/README.md index 1b95c775040..556b1d45d18 100644 --- a/kyu_6/color_choice/README.md +++ b/kyu_6/color_choice/README.md @@ -54,4 +54,4 @@ checkchoose(a, 50) --> 20 checkchoose(a + 1, 50) --> -1 ``` -[Source](https://www.codewars.com/kata/55be10de92aad5ef28000023/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/55be10de92aad5ef28000023) \ No newline at end of file diff --git a/kyu_6/color_choice/test_checkchoose.py b/kyu_6/color_choice/test_checkchoose.py index df58b487ce8..c54e574b029 100644 --- a/kyu_6/color_choice/test_checkchoose.py +++ b/kyu_6/color_choice/test_checkchoose.py @@ -20,7 +20,7 @@ @allure.story('Color Choice') @allure.tag('FUNDAMENTALS') @allure.link( - url='https://www.codewars.com/kata/55be10de92aad5ef28000023/train/python', + url='https://www.codewars.com/kata/55be10de92aad5ef28000023', name='Source/Kata') class CheckchooseTestCase(unittest.TestCase): """ @@ -58,7 +58,7 @@ def test_checkchoose(self): "that when m is given at random there are no x satisfying " "equation (1) then return -1.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (6, 4, 2), (4, 4, 1), (4, 2, -1), diff --git a/kyu_6/count_letters_in_string/README.md b/kyu_6/count_letters_in_string/README.md index 797235df5e2..819db48f4d7 100644 --- a/kyu_6/count_letters_in_string/README.md +++ b/kyu_6/count_letters_in_string/README.md @@ -10,4 +10,4 @@ Example: > letter_count('arithmetics') #=> {"a": 1, "c": 1, "e": 1, "h": 1, "i": 2, "m": 1, "r": 1, "s": 1, "t": 2} -[Source](https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d) \ No newline at end of file diff --git a/kyu_6/count_letters_in_string/test_count_letters_in_string.py b/kyu_6/count_letters_in_string/test_count_letters_in_string.py index 7e341742528..27262ebe2bb 100644 --- a/kyu_6/count_letters_in_string/test_count_letters_in_string.py +++ b/kyu_6/count_letters_in_string/test_count_letters_in_string.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.count_letters_in_string.count_letters_in_string import letter_count +from kyu_6.count_letters_in_string.count_letters_in_string \ + import letter_count # pylint: disable-msg=R0801 @@ -24,13 +25,14 @@ 'HASHES', 'DATA STRUCTURES') @allure.link( - url='https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d/train/python', + url='https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d', name='Source/Kata') # pylint: enable-msg=R0801 class CountLettersInStringTestCase(unittest.TestCase): """ Testing 'letter_count' function """ + def test_count_letters_in_string(self): """ Testing 'letter_count' function @@ -47,9 +49,9 @@ def test_count_letters_in_string(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - string = "codewars" - expected = {"a": 1, "c": 1, "d": 1, "e": 1, - "o": 1, "r": 1, "s": 1, "w": 1} + string: str = "codewars" + expected: dict = {"a": 1, "c": 1, "d": 1, "e": 1, + "o": 1, "r": 1, "s": 1, "w": 1} print_log(string=string, expected=expected) self.assertEqual(expected, letter_count(string)) diff --git a/kyu_6/decipher_this/README.md b/kyu_6/decipher_this/README.md index f2921d12b91..a7bca4e5c4b 100644 --- a/kyu_6/decipher_this/README.md +++ b/kyu_6/decipher_this/README.md @@ -17,4 +17,4 @@ decipherThis('72olle 103doo 100ya'); // 'Hello good day' decipherThis('82yade 115te 103o'); // 'Ready set go' ``` -[Source](https://www.codewars.com/kata/581e014b55f2c52bb00000f8/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/581e014b55f2c52bb00000f8) \ No newline at end of file diff --git a/kyu_6/decipher_this/test_decipher_this.py b/kyu_6/decipher_this/test_decipher_this.py index 6c6bf3bfd0e..53ad831941b 100644 --- a/kyu_6/decipher_this/test_decipher_this.py +++ b/kyu_6/decipher_this/test_decipher_this.py @@ -28,7 +28,7 @@ 'CRYPTOGRAPHY', 'SECURITY') @allure.link( - url='https://www.codewars.com/kata/581e014b55f2c52bb00000f8/train/python', + url='https://www.codewars.com/kata/581e014b55f2c52bb00000f8', name='Source/Kata') # pylint: enable-msg=R0801 class DecipherThisTestCase(unittest.TestCase): @@ -59,7 +59,7 @@ def test_decipher_this(self): "letters and spaces." "

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("", ""), ('72olle 103doo 100ya', @@ -78,7 +78,7 @@ def test_decipher_this(self): "Thank you Piotr for all your help")) for text, expected in test_data: - result = decipher_this(text) + result: str = decipher_this(text) print_log(text=text, expected=expected, result=result) diff --git a/kyu_6/default_list/README.md b/kyu_6/default_list/README.md index 81df3582466..83db1479339 100644 --- a/kyu_6/default_list/README.md +++ b/kyu_6/default_list/README.md @@ -25,4 +25,4 @@ lst.extend([104, 1044, 4066, -2]) lst[9] = -2 ``` -[Source](https://www.codewars.com/kata/5e882048999e6c0023412908/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5e882048999e6c0023412908) \ No newline at end of file diff --git a/kyu_6/default_list/test_default_list.py b/kyu_6/default_list/test_default_list.py index 26b07685cff..b9b0134a607 100644 --- a/kyu_6/default_list/test_default_list.py +++ b/kyu_6/default_list/test_default_list.py @@ -23,8 +23,9 @@ 'CLASSES', 'BASIC LANGUAGE FEATURES', 'OBJECT-ORIENTED PROGRAMMING') -@allure.link(url='https://www.codewars.com/kata/5e882048999e6c0023412908/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5e882048999e6c0023412908', + name='Source/Kata') class DefaultListTestCase(unittest.TestCase): """ Testing 'DefaultList' class @@ -41,6 +42,7 @@ class DefaultListTestCase(unittest.TestCase): This class must also support the regular list functions extend, append, insert, remove, and pop. """ + def test_default_list_basic(self): """ Testing 'DefaultList' class: __getitem__ @@ -67,7 +69,7 @@ def test_default_list_basic(self): lst = DefaultList([1, 3, 4, 7, 2, 34], 'def') with allure.step("Get list item by index and verify the results"): - i = 1 + i: int = 1 expected = 3 actual = lst[i] print_log(lst=lst, i=i, expected=expected, actual=actual) @@ -75,17 +77,17 @@ def test_default_list_basic(self): with allure.step("Get list item by index and verify the results"): i = 333000 - expected = 'def' + expected_str = 'def' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) with allure.step("Get list item by index and verify the results"): i = 23 - expected = 'def' + expected_str = 'def' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) def test_default_list_extend(self): """ @@ -110,10 +112,10 @@ def test_default_list_extend(self): with allure.step("Get list item by index and verify the results"): i = 9 - expected = 'lists' + expected_str = 'lists' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) with allure.step("Get list item by index and verify the results"): i = 11 @@ -124,10 +126,10 @@ def test_default_list_extend(self): with allure.step("Get list item by index and verify the results"): i = 12 - expected = 'def' + expected_str = 'def' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) def test_default_list_append(self): """ @@ -161,10 +163,10 @@ def test_default_list_append(self): with allure.step("Get list item by index and verify the results"): i = 100 - expected = 'def' + expected_str = 'def' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) def test_default_list_remove(self): """ @@ -230,10 +232,10 @@ def test_default_list_insert(self): with allure.step("Get list item by index and verify the results"): i = 8 - expected = 'word' + expected_str = 'word' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) with allure.step("Get list item by index and verify the results"): i = 10 @@ -264,21 +266,21 @@ def test_default_list_pop(self): with allure.step("Pop an item and verify the result"): i = 5 - expected = 'hello' + expected_str = 'hello' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) with allure.step("Pop an item and verify the result"): i = 6 - expected = 'lists' + expected_str = 'lists' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) with allure.step("Pop an un-existing item and verify the result"): i = 45 - expected = 'def' + expected_str = 'def' actual = lst[i] - print_log(lst=lst, i=i, expected=expected, actual=actual) - self.assertEqual(expected, actual) + print_log(lst=lst, i=i, expected=expected_str, actual=actual) + self.assertEqual(expected_str, actual) diff --git a/kyu_6/disease_spread/README.md b/kyu_6/disease_spread/README.md index a591d699b7f..472ee25d055 100644 --- a/kyu_6/disease_spread/README.md +++ b/kyu_6/disease_spread/README.md @@ -56,4 +56,4 @@ Keeping track of the values of susceptibles, infecteds and recovereds you can plot the solutions of the 3 differential equations. See an example below on the plot. -[Source](https://www.codewars.com/kata/566543703c72200f0b0000c9/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/566543703c72200f0b0000c9) \ No newline at end of file diff --git a/kyu_6/disease_spread/test_epidemic.py b/kyu_6/disease_spread/test_epidemic.py index 25c26a683bb..e9bea6a5946 100644 --- a/kyu_6/disease_spread/test_epidemic.py +++ b/kyu_6/disease_spread/test_epidemic.py @@ -21,7 +21,7 @@ @allure.story('Disease Spread') @allure.tag('FUNDAMENTALS') @allure.link( - url='https://www.codewars.com/kata/566543703c72200f0b0000c9/train/python', + url='https://www.codewars.com/kata/566543703c72200f0b0000c9', name='Source/Kata') class EpidemicTestCase(unittest.TestCase): """ @@ -45,7 +45,7 @@ def test_epidemic(self): "of max(I)).

    ") # pylint: enable-msg=R0801 # tm , n, s0, i0, b, a, expected - test_data = ( + test_data: tuple = ( EpidemicTestData(tm=18, n=432, s0=1004, i0=1, b=0.00209, a=0.51, expected=420), EpidemicTestData(tm=12, n=288, s0=1007, i0=2, @@ -65,8 +65,7 @@ def test_epidemic(self): EpidemicTestData(tm=13, n=312, s0=993, i0=2, b=0.0021, a=0.51, expected=414), EpidemicTestData(tm=28, n=672, s0=999, i0=1, - b=0.00197, a=0.55, expected=368) - ) + b=0.00197, a=0.55, expected=368)) for etd in test_data: tm = etd.tm diff --git a/kyu_6/duplicate_encoder/README.md b/kyu_6/duplicate_encoder/README.md index ab2ea1bcd98..d7504e59712 100644 --- a/kyu_6/duplicate_encoder/README.md +++ b/kyu_6/duplicate_encoder/README.md @@ -22,4 +22,4 @@ Assertion messages may be unclear about what they display in some languages. If you read `"...It Should encode XXX"`, the `"XXX"` is the expected result, not the input! -[Source](https://www.codewars.com/kata/54b42f9314d9229fd6000d9c/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/54b42f9314d9229fd6000d9c) \ No newline at end of file diff --git a/kyu_6/duplicate_encoder/duplicate_encode.py b/kyu_6/duplicate_encoder/duplicate_encode.py index c24533cd5c5..b9a4e1e7a3a 100644 --- a/kyu_6/duplicate_encoder/duplicate_encode.py +++ b/kyu_6/duplicate_encoder/duplicate_encode.py @@ -20,7 +20,7 @@ def duplicate_encode(word: str) -> str: """ result: str = '' - word: str = ''.join(char.lower() for char in word) + word = ''.join(char.lower() for char in word) for char in word: if word.count(char) > 1: diff --git a/kyu_6/duplicate_encoder/test_duplicate_encode.py b/kyu_6/duplicate_encoder/test_duplicate_encode.py index c0d35329468..9b1dc61390d 100644 --- a/kyu_6/duplicate_encoder/test_duplicate_encode.py +++ b/kyu_6/duplicate_encoder/test_duplicate_encode.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.duplicate_encoder.duplicate_encode import duplicate_encode +from kyu_6.duplicate_encoder.duplicate_encode \ + import duplicate_encode # pylint: disable-msg=R0801 @@ -23,7 +24,7 @@ 'STRINGS', 'ARRAYS') @allure.link( - url='https://www.codewars.com/kata/54b42f9314d9229fd6000d9c/train/python', + url='https://www.codewars.com/kata/54b42f9314d9229fd6000d9c', name='Source/Kata') # pylint: enable-msg=R0801 class DuplicateEncodeTestCase(unittest.TestCase): @@ -47,11 +48,11 @@ def test_duplicate_encode(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ("din", "((("), ("recede", "()()()"), ("Success", ")())())"), - ("(( @", "))((")] + ("(( @", "))((")) for string, expected in test_data: print_log(string=string, expected=expected) diff --git a/kyu_6/easy_diagonal/README.md b/kyu_6/easy_diagonal/README.md index bc340d1b489..5a728b158cd 100644 --- a/kyu_6/easy_diagonal/README.md +++ b/kyu_6/easy_diagonal/README.md @@ -35,4 +35,4 @@ the numbers on the diagonal at its right. References: * [Binomial Coefficient](http://mathworld.wolfram.com/BinomialCoefficient.html) -* [Source](https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf/train/python) \ No newline at end of file +* [Source](https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf) \ No newline at end of file diff --git a/kyu_6/easy_diagonal/test_diagonal.py b/kyu_6/easy_diagonal/test_diagonal.py index 2be24473c2e..2bf2658cf74 100644 --- a/kyu_6/easy_diagonal/test_diagonal.py +++ b/kyu_6/easy_diagonal/test_diagonal.py @@ -20,7 +20,7 @@ @allure.tag("FUNDAMENTALS", "ALGORITHMS") @allure.link( - url='https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf/train/python', + url='https://www.codewars.com/kata/559b8e46fa060b2c6a0000bf', name='Source/Kata') # pylint: enable-msg=R0801 class EasyDiagonalTestCase(unittest.TestCase): @@ -48,7 +48,7 @@ def test_easy_diagonal(self): " 0 is the number of the diagonal). In the same way S(7, 1) " "is 28, S(7, 2) is 56.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (7, 0, 8), (7, 1, 28), (7, 2, 56), @@ -57,8 +57,7 @@ def test_easy_diagonal(self): (20, 4, 20349), (20, 15, 20349), (1291, 5, 6385476296235036), - (129100, 5, 6429758786797926366807779220), - ) + (129100, 5, 6429758786797926366807779220)) for td in test_data: n = td[0] diff --git a/kyu_6/encrypt_this/README.md b/kyu_6/encrypt_this/README.md index 9d77a1e366d..f5bb1fee583 100644 --- a/kyu_6/encrypt_this/README.md +++ b/kyu_6/encrypt_this/README.md @@ -23,4 +23,4 @@ encrypt_this("good") == "103doo" encrypt_this("hello world") == "104olle 119drlo" ``` -[Source](https://www.codewars.com/kata/5848565e273af816fb000449/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5848565e273af816fb000449) \ No newline at end of file diff --git a/kyu_6/encrypt_this/test_encrypt_this.py b/kyu_6/encrypt_this/test_encrypt_this.py index e7076f532de..6e59abe6823 100644 --- a/kyu_6/encrypt_this/test_encrypt_this.py +++ b/kyu_6/encrypt_this/test_encrypt_this.py @@ -5,7 +5,8 @@ """ # FUNDAMENTALS STRINGS REGULAR EXPRESSIONS DECLARATIVE PROGRAMMING -# ADVANCED LANGUAGE FEATURES ARRAYS CIPHERS ALGORITHMS CRYPTOGRAPHY SECURITY +# ADVANCED LANGUAGE FEATURES ARRAYS CIPHERS ALGORITHMS CRYPTOGRAPHY +# SECURITY import unittest import allure @@ -31,7 +32,7 @@ 'CRYPTOGRAPHY', 'SECURITY') @allure.link( - url='https://www.codewars.com/kata/5848565e273af816fb000449/train/python', + url='https://www.codewars.com/kata/5848565e273af816fb000449', name='Source/Kata') # pylint: enable-msg=R0801 class EncryptThisTestCase(unittest.TestCase): @@ -61,7 +62,7 @@ def test_encrypt_this(self): "Keepin' it simple: There are no special characters in input." "

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("", ""), ("Hello", @@ -79,8 +80,7 @@ def test_encrypt_this(self): ("Why can we not all be like that wise old bird", "87yh 99na 119e 110to 97ll 98e 108eki 116tah 119esi 111dl 98dri"), ("Thank you Piotr for all your help", - "84kanh 121uo 80roti 102ro 97ll 121ruo 104ple") - ) + "84kanh 121uo 80roti 102ro 97ll 121ruo 104ple")) for text, expected in test_data: result = encrypt_this(text) diff --git a/kyu_6/find_the_odd_int/README.md b/kyu_6/find_the_odd_int/README.md index f133eb6ffb7..f9c66046943 100644 --- a/kyu_6/find_the_odd_int/README.md +++ b/kyu_6/find_the_odd_int/README.md @@ -14,4 +14,4 @@ There will always be only one integer that appears an odd number of times. [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd). ``` -[Source](https://www.codewars.com/kata/54da5a58ea159efa38000836/train/python) +[Source](https://www.codewars.com/kata/54da5a58ea159efa38000836) diff --git a/kyu_6/find_the_odd_int/test_find_the_odd_int.py b/kyu_6/find_the_odd_int/test_find_the_odd_int.py index 8926e3ba236..45c89d3fa63 100644 --- a/kyu_6/find_the_odd_int/test_find_the_odd_int.py +++ b/kyu_6/find_the_odd_int/test_find_the_odd_int.py @@ -43,7 +43,7 @@ def test_something(self): '

    Test Description:

    ' "

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([20, 1, -1, 2, -2, 3, 3, 5, 5, 1, 2, 4, 20, 4, -1, -2, 5], 5, 'should return 5 (because it appears 3 times)'), diff --git a/kyu_6/first_character_that_repeats/README.md b/kyu_6/first_character_that_repeats/README.md index 3a4f389ac0b..03d5275c866 100644 --- a/kyu_6/first_character_that_repeats/README.md +++ b/kyu_6/first_character_that_repeats/README.md @@ -9,4 +9,4 @@ Find the first character that repeats in a String and return that character. This is not the same as finding the character that repeats first. In that case, an input of 'tweet' would yield 'e'. -[Source](https://www.codewars.com/kata/54f9f4d7c41722304e000bbb/train/python) +[Source](https://www.codewars.com/kata/54f9f4d7c41722304e000bbb) diff --git a/kyu_6/first_character_that_repeats/first_character_that_repeats.py b/kyu_6/first_character_that_repeats/first_character_that_repeats.py index e22086dfaec..a228b4a93e1 100644 --- a/kyu_6/first_character_that_repeats/first_character_that_repeats.py +++ b/kyu_6/first_character_that_repeats/first_character_that_repeats.py @@ -5,7 +5,7 @@ """ -def first_dup(word: str) -> (str, None): +def first_dup(word: str) -> str | None: """ Find the first character that repeats in a String and return that character. diff --git a/kyu_6/first_character_that_repeats/test_first_character_that_repeats.py b/kyu_6/first_character_that_repeats/test_first_character_that_repeats.py index 7f25e9bee55..a8a388decb0 100644 --- a/kyu_6/first_character_that_repeats/test_first_character_that_repeats.py +++ b/kyu_6/first_character_that_repeats/test_first_character_that_repeats.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.first_character_that_repeats.first_character_that_repeats import first_dup +from kyu_6.first_character_that_repeats.first_character_that_repeats \ + import first_dup # pylint: disable-msg=R0801 @@ -46,7 +47,7 @@ def test_first_dup_none(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass string with no repeating chars"): - string = 'like' + string: str = 'like' expected = None print_log(string=string, expected=expected) @@ -75,7 +76,7 @@ def test_first_dup_mixed(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Input consist of mixed type of chars"): - string = '1a2b3a3c' + string: str = '1a2b3a3c' expected = 'a' print_log(string=string, expected=expected) @@ -104,7 +105,7 @@ def test_first_alpha_only(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Input consist of alphabet chars only"): - string = 'tweet' + string: str = 'tweet' expected = 't' print_log(string=string, expected=expected) @@ -126,7 +127,7 @@ def test_first_space(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Input consist of alphabet chars and spaces"): - string = 'Ode to Joy' + string: str = 'Ode to Joy' expected = ' ' print_log(string=string, expected=expected) @@ -148,7 +149,7 @@ def test_first_no_alpha(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass string with digits only"): - string = '123123' + string: str = '123123' expected = '1' print_log(string=string, expected=expected) diff --git a/kyu_6/format_string_of_names/README.md b/kyu_6/format_string_of_names/README.md index 96153bddd2a..b8e78b74af5 100644 --- a/kyu_6/format_string_of_names/README.md +++ b/kyu_6/format_string_of_names/README.md @@ -27,4 +27,4 @@ namelist([]) Note: all the hashes are pre-validated and will only contain A-Z, a-z, '-' and '.'. -[Source](https://www.codewars.com/kata/53368a47e38700bd8300030d/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/53368a47e38700bd8300030d) \ No newline at end of file diff --git a/kyu_6/format_string_of_names/test_namelist.py b/kyu_6/format_string_of_names/test_namelist.py index 1559dec13de..428fe8beaa1 100644 --- a/kyu_6/format_string_of_names/test_namelist.py +++ b/kyu_6/format_string_of_names/test_namelist.py @@ -23,7 +23,7 @@ 'FORMATTING', 'ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/53368a47e38700bd8300030d/train/python', + url='https://www.codewars.com/kata/53368a47e38700bd8300030d', name='Source/Kata') # pylint: enable-msg=R0801 class NamelistTestCase(unittest.TestCase): @@ -56,7 +56,7 @@ def test_namelist(self): "by commas except for the last two names, which should be " "separated by an ampersand.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([{'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'}, {'name': 'Homer'}, {'name': 'Marge'}], 'Bart, Lisa, Maggie, Homer & Marge', @@ -72,11 +72,10 @@ def test_namelist(self): "Wrong output for a single name"), ([], '', - "Must work with no names"), - ) + "Must work with no names")) for names, expected, message in test_data: - result = namelist(names) + result: str = namelist(names) print_log(names=names, expected=expected, result=result, diff --git a/kyu_6/help_the_bookseller/README.md b/kyu_6/help_the_bookseller/README.md index 56d16d505da..27cc4d53b46 100644 --- a/kyu_6/help_the_bookseller/README.md +++ b/kyu_6/help_the_bookseller/README.md @@ -54,4 +54,4 @@ Note: In the result codes and their values are in the same order as in M. -[Source](https://www.codewars.com/kata/54dc6f5a224c26032800005c/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/54dc6f5a224c26032800005c) \ No newline at end of file diff --git a/kyu_6/help_the_bookseller/test_stock_list.py b/kyu_6/help_the_bookseller/test_stock_list.py index ba1d8ad14c5..d21c275c48e 100644 --- a/kyu_6/help_the_bookseller/test_stock_list.py +++ b/kyu_6/help_the_bookseller/test_stock_list.py @@ -21,7 +21,7 @@ @allure.tag('FUNDAMENTALS', 'ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/54dc6f5a224c26032800005c/train/python', + url='https://www.codewars.com/kata/54dc6f5a224c26032800005c', name='Source/Kata') class StockListTestCase(unittest.TestCase): """ @@ -46,7 +46,7 @@ def test_stock_list(self): "to each category of M and to sum their quantity according to " "each category.

    ") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (["ABAR 200", "CDXE 500", "BKWR 250", "BTSQ 890", "DRTY 600"], ["A", "B"], "(A : 200) - (B : 1140)"), @@ -66,8 +66,7 @@ def test_stock_list(self): '(U : 0) - (V : 0) - (R : 225)'), ([], ['B', 'R', 'D', 'X'], - '') - ] + '')) for list_of_art, list_of_cat, expected in test_data: actual_result = stock_list(list_of_art, list_of_cat) diff --git a/kyu_6/longest_repetition/README.md b/kyu_6/longest_repetition/README.md index 43d82faf19c..ec695259dc1 100644 --- a/kyu_6/longest_repetition/README.md +++ b/kyu_6/longest_repetition/README.md @@ -12,4 +12,4 @@ For empty string return: > ('', 0) -[Source](https://www.codewars.com/kata/586d6cefbcc21eed7a001155/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/586d6cefbcc21eed7a001155) \ No newline at end of file diff --git a/kyu_6/longest_repetition/test_longest_repetition.py b/kyu_6/longest_repetition/test_longest_repetition.py index 324350175f5..75f5fb9b93c 100644 --- a/kyu_6/longest_repetition/test_longest_repetition.py +++ b/kyu_6/longest_repetition/test_longest_repetition.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.longest_repetition.longest_repetition import longest_repetition +from kyu_6.longest_repetition.longest_repetition \ + import longest_repetition # pylint: disable-msg=R0801 @@ -23,7 +24,7 @@ 'STRINGS', 'FUNDAMENTALS') @allure.link( - url='https://www.codewars.com/kata/586d6cefbcc21eed7a001155/train/python', + url='https://www.codewars.com/kata/586d6cefbcc21eed7a001155', name='Source/Kata') # pylint: enable-msg=R0801 class LongestRepetitionTestCase(unittest.TestCase): @@ -50,7 +51,7 @@ def test_longest_repetition(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass string and verify the output"): - test_data = [ + test_data: tuple = ( # [input, expected], ["aaaabb", ('a', 4)], ["bbbaaabaaaa", ('a', 4)], @@ -58,7 +59,7 @@ def test_longest_repetition(self): ["abbbbb", ('b', 5)], ["aabb", ('a', 2)], ["ba", ('b', 1)], - ["", ('', 0)]] + ["", ('', 0)]) for t in test_data: print_log(string=t[0], expected=t[1]) diff --git a/kyu_6/multiples_of_3_or_5/README.md b/kyu_6/multiples_of_3_or_5/README.md index dbf5182e0c8..fd6fba5a933 100644 --- a/kyu_6/multiples_of_3_or_5/README.md +++ b/kyu_6/multiples_of_3_or_5/README.md @@ -8,4 +8,4 @@ of 3 or 5 *below* the number passed in. > Note: If the number is a multiple of both 3 and 5, only count it once. -[Source](https://www.codewars.com/kata/514b92a657cdc65150000006/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/514b92a657cdc65150000006) \ No newline at end of file diff --git a/kyu_6/multiples_of_3_or_5/test_solution.py b/kyu_6/multiples_of_3_or_5/test_solution.py index bde5d0c67b8..aaceb0419d1 100644 --- a/kyu_6/multiples_of_3_or_5/test_solution.py +++ b/kyu_6/multiples_of_3_or_5/test_solution.py @@ -22,7 +22,7 @@ 'MATHEMATICS', 'NUMBERS') @allure.link( - url='https://www.codewars.com/kata/514b92a657cdc65150000006/train/python', + url='https://www.codewars.com/kata/514b92a657cdc65150000006', name='Source/Kata') class SolutionTestCase(unittest.TestCase): """ @@ -57,8 +57,7 @@ def test_solution(self): (4, 3, 'Should return 3 for n=4'), (200, 9168, 'Should return 9168 for n=200'), (-1, 0, 'Should return 0 for n=-1'), - (1291, 388935, 'Random test') - ) + (1291, 388935, 'Random test')) for td in test_data: number, expected, msg = td diff --git a/kyu_6/no_arithmetic_progressions/README.md b/kyu_6/no_arithmetic_progressions/README.md index d1b01e5f3b2..b9eb7af18c5 100644 --- a/kyu_6/no_arithmetic_progressions/README.md +++ b/kyu_6/no_arithmetic_progressions/README.md @@ -25,4 +25,4 @@ Write a function f(n), which returns the n-th member of sequence. There are 1000 random tests with 0 <= n <= 10^9, so you should consider algorithmic complexity of your solution. -[Source](https://www.codewars.com/kata/5e0607115654a900140b3ce3/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5e0607115654a900140b3ce3) \ No newline at end of file diff --git a/kyu_6/no_arithmetic_progressions/test_sequence.py b/kyu_6/no_arithmetic_progressions/test_sequence.py index 11daead676d..1690ece844c 100644 --- a/kyu_6/no_arithmetic_progressions/test_sequence.py +++ b/kyu_6/no_arithmetic_progressions/test_sequence.py @@ -24,7 +24,7 @@ @allure.story('No arithmetic progressions') @allure.tag('ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/5e0607115654a900140b3ce3/train/python', + url='https://www.codewars.com/kata/5e0607115654a900140b3ce3', name='Source/Kata') # pylint: enable-msg=R0801 @pytest.mark.skip(reason="The solution is not ready") diff --git a/kyu_6/number_zoo_patrol/README.md b/kyu_6/number_zoo_patrol/README.md index ea87a16d47a..c9fdb22d2a2 100644 --- a/kyu_6/number_zoo_patrol/README.md +++ b/kyu_6/number_zoo_patrol/README.md @@ -16,4 +16,4 @@ Note: huge lists will be tested. [4, 2, 3] => 1 ``` -[Source](https://www.codewars.com/kata/5276c18121e20900c0000235/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5276c18121e20900c0000235) \ No newline at end of file diff --git a/kyu_6/number_zoo_patrol/test_find_missing_number.py b/kyu_6/number_zoo_patrol/test_find_missing_number.py index 740aca0699e..b414c468be7 100644 --- a/kyu_6/number_zoo_patrol/test_find_missing_number.py +++ b/kyu_6/number_zoo_patrol/test_find_missing_number.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.number_zoo_patrol.missing_number import find_missing_number +from kyu_6.number_zoo_patrol.missing_number \ + import find_missing_number # pylint: disable-msg=R0801 @allure.epic('6 kyu') @@ -23,7 +24,7 @@ 'MATHEMATICS', 'NUMBERS') @allure.link( - url='https://www.codewars.com/kata/5276c18121e20900c0000235/train/python', + url='https://www.codewars.com/kata/5276c18121e20900c0000235', name='Source/Kata') # pylint: enable-msg=R0801 class FindMissingNumberTestCase(unittest.TestCase): @@ -52,7 +53,7 @@ def test_find_missing_number(self): "(which can be any number including n). The function should" " return the missing number.

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ([2, 3, 4], 1), ([1, 3, 4], 2), ([1, 2, 4], 3), @@ -89,8 +90,7 @@ def test_find_missing_number(self): 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, - 500], 36), - ) + 500], 36)) for data in test_data: numbers: list = data[0] diff --git a/kyu_6/numericals_of_string/README.md b/kyu_6/numericals_of_string/README.md index 62ee9940341..10ab386dafa 100644 --- a/kyu_6/numericals_of_string/README.md +++ b/kyu_6/numericals_of_string/README.md @@ -20,4 +20,4 @@ But will your code be **performant enough**? There might be some non-ascii characters in the string. -[Source](https://www.codewars.com/kata/5b4070144d7d8bbfe7000001/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5b4070144d7d8bbfe7000001) \ No newline at end of file diff --git a/kyu_6/numericals_of_string/test_numericals.py b/kyu_6/numericals_of_string/test_numericals.py index 06e21ec7938..eca29da562f 100644 --- a/kyu_6/numericals_of_string/test_numericals.py +++ b/kyu_6/numericals_of_string/test_numericals.py @@ -47,41 +47,31 @@ def test_numericals(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass the string and verify the output"): - string = "Hello, World!" - expected = "1112111121311" - + string: str = "Hello, World!" + expected: str = "1112111121311" print_log(string=string, expected=expected) - self.assertEqual(numericals(string), expected) with allure.step("Pass the string and verify the output"): string = "Hello, World! It's me, JomoPipi!" expected = "11121111213112111131224132411122" - print_log(string=string, expected=expected) - self.assertEqual(numericals(string), expected) with allure.step("Pass the string and verify the output"): string = "hello hello" expected = "11121122342" - print_log(string=string, expected=expected) - self.assertEqual(numericals(string), expected) with allure.step("Pass the string and verify the output"): string = "Hello" expected = "11121" - print_log(string=string, expected=expected) - self.assertEqual(numericals(string), expected) with allure.step("Pass the string and verify the output"): string = "aaaaaaaaaaaa" expected = "123456789101112" - print_log(string=string, expected=expected) - self.assertEqual(numericals(string), expected) diff --git a/kyu_6/permute_a_palindrome/README.md b/kyu_6/permute_a_palindrome/README.md index db2d2506948..781d976a28c 100644 --- a/kyu_6/permute_a_palindrome/README.md +++ b/kyu_6/permute_a_palindrome/README.md @@ -19,4 +19,4 @@ permutations of the string and check each one of them whether it is a palindrome. However, an optimized approach will not require this at all. -[Source](https://www.codewars.com/kata/58ae6ae22c3aaafc58000079/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/58ae6ae22c3aaafc58000079) \ No newline at end of file diff --git a/kyu_6/permute_a_palindrome/test_permute_a_palindrome.py b/kyu_6/permute_a_palindrome/test_permute_a_palindrome.py index 5ff1cf1cb69..961cc4f1c27 100644 --- a/kyu_6/permute_a_palindrome/test_permute_a_palindrome.py +++ b/kyu_6/permute_a_palindrome/test_permute_a_palindrome.py @@ -20,12 +20,14 @@ @allure.story('Permute a Palindrome') @allure.tag('FUNDAMENTALS', 'ALGORITHMS') -@allure.link(url='https://www.codewars.com/kata/58ae6ae22c3aaafc58000079/train/python', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/58ae6ae22c3aaafc58000079', + name='Source/Kata') class PermutePalindromeTestCase(unittest.TestCase): """ Testing permute_a_palindrome function """ + def test_permute_a_palindrome_positive(self): """ Testing permute_a_palindrome function @@ -43,35 +45,27 @@ def test_permute_a_palindrome_positive(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the result"): - string = "a" - expected = True - + string: str = "a" + expected: bool = True print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) with allure.step("Enter test string and verify the result"): string = "aa" expected = True - print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) with allure.step("Enter test string and verify the result"): string = "baa" expected = True - print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) with allure.step("Enter test string and verify the result"): string = "aab" expected = True - print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) def test_permute_a_palindrome_negative(self): @@ -91,27 +85,21 @@ def test_permute_a_palindrome_negative(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the result"): - string = "baabcd" - expected = False - + string: str = "baabcd" + expected: bool = False print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) with allure.step("Enter test string and verify the result"): string = "racecars" expected = False - print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) with allure.step("Enter test string and verify the result"): string = "abcdefghba" expected = False - print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) def test_permute_a_palindrome_empty_string(self): @@ -131,9 +119,7 @@ def test_permute_a_palindrome_empty_string(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter empty string and verify the result"): - string = '' - expected = True - + string: str = '' + expected: bool = True print_log(string=string, expected=expected) - self.assertEqual(permute_a_palindrome(string), expected) diff --git a/kyu_6/pokemon_damage_calculator/README.md b/kyu_6/pokemon_damage_calculator/README.md index 764397773ed..66cb5f31377 100644 --- a/kyu_6/pokemon_damage_calculator/README.md +++ b/kyu_6/pokemon_damage_calculator/README.md @@ -47,4 +47,4 @@ The function you must implement takes in: 3. your attack power 4. the opponent's defense -[Source](https://www.codewars.com/kata/536e9a7973130a06eb000e9f/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/536e9a7973130a06eb000e9f) \ No newline at end of file diff --git a/kyu_6/pokemon_damage_calculator/test_calculate_damage.py b/kyu_6/pokemon_damage_calculator/test_calculate_damage.py index fb82cb0a352..766704a4d5c 100644 --- a/kyu_6/pokemon_damage_calculator/test_calculate_damage.py +++ b/kyu_6/pokemon_damage_calculator/test_calculate_damage.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.pokemon_damage_calculator.calculate_damage import calculate_damage +from kyu_6.pokemon_damage_calculator.calculate_damage \ + import calculate_damage @allure.epic('6 kyu') @@ -29,7 +30,7 @@ 'BASIC LANGUAGE FEATURES', 'FUNDAMENTALS') @allure.link( - url='https://www.codewars.com/kata/536e9a7973130a06eb000e9f/train/python', + url='https://www.codewars.com/kata/536e9a7973130a06eb000e9f', name='Source/Kata') class CalculateDamageTestCase(unittest.TestCase): """ @@ -54,15 +55,14 @@ def test_calculate_damage(self): " formula (not the actual one from the game): " "damage = 50 * (attack / defense) * effectiveness

    ") # pylint: enable-msg=R0801 - test_data = [ + test_data: tuple = ( (("fire", "water", 100, 100), 25), (("grass", "water", 100, 100), 100), (("electric", "fire", 100, 100), 50), (("grass", "electric", 57, 19), 150), (("grass", "water", 40, 40), 100), (("grass", "fire", 35, 5), 175), - (("fire", "electric", 10, 2), 250), - ] + (("fire", "electric", 10, 2), 250)) for test_data, expected in test_data: your_type = test_data[0] diff --git a/kyu_6/potion_class_101/README.md b/kyu_6/potion_class_101/README.md index b7e56171322..3afe8ff6fae 100644 --- a/kyu_6/potion_class_101/README.md +++ b/kyu_6/potion_class_101/README.md @@ -34,4 +34,4 @@ new_potion.volume == 19 **Note:** Use ceiling when calculating the resulting potion's color. -[Source](https://www.codewars.com/kata/5981ff1daf72e8747d000091/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5981ff1daf72e8747d000091) \ No newline at end of file diff --git a/kyu_6/potion_class_101/test_potion.py b/kyu_6/potion_class_101/test_potion.py index 5c977adc335..c964e3992b8 100644 --- a/kyu_6/potion_class_101/test_potion.py +++ b/kyu_6/potion_class_101/test_potion.py @@ -19,7 +19,7 @@ @allure.story('Potion Class 101') @allure.tag('ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/5981ff1daf72e8747d000091/train/python', + url='https://www.codewars.com/kata/5981ff1daf72e8747d000091', name='Source/Kata') class PotionTestCase(unittest.TestCase): """ @@ -40,14 +40,13 @@ def test_potion(self): '

    Test Description:

    ' "

    Test Potion class that mix between 2 RGB colors.

    ") # pylint: enable-msg=R0801 - potions = [ + potions: list = [ Potion((153, 210, 199), 32), Potion((135, 34, 0), 17), Potion((18, 19, 20), 25), Potion((174, 211, 13), 4), Potion((255, 23, 148), 19), - Potion((51, 102, 51), 6) - ] + Potion((51, 102, 51), 6)] a = potions[0].mix(potions[1]) b = potions[0].mix(potions[2]).mix(potions[4]) diff --git a/kyu_6/pyramid_array/test_pyramid_array.py b/kyu_6/pyramid_array/test_pyramid_array.py index 9866d2a853d..1ab3cc3e595 100644 --- a/kyu_6/pyramid_array/test_pyramid_array.py +++ b/kyu_6/pyramid_array/test_pyramid_array.py @@ -53,19 +53,19 @@ def test_pyramid(self): self.assertEqual(pyramid(n), expected) with allure.step("Pass one"): - n: int = 1 - expected: list = [[1]] + n = 1 + expected = [[1]] print_log(n=n, expected=expected) self.assertEqual(pyramid(n), expected) with allure.step("Pass two"): - n: int = 2 - expected: list = [[1], [1, 1]] + n = 2 + expected = [[1], [1, 1]] print_log(n=n, expected=expected) self.assertEqual(pyramid(n), expected) with allure.step("Pass three"): - n: int = 3 - expected: list = [[1], [1, 1], [1, 1, 1]] + n = 3 + expected = [[1], [1, 1], [1, 1, 1]] print_log(n=n, expected=expected) self.assertEqual(pyramid(n), expected) diff --git a/kyu_6/rotate_the_letters_of_each_element/group_cities.py b/kyu_6/rotate_the_letters_of_each_element/group_cities.py index 701e7b28dc7..506c7ed7f88 100644 --- a/kyu_6/rotate_the_letters_of_each_element/group_cities.py +++ b/kyu_6/rotate_the_letters_of_each_element/group_cities.py @@ -47,7 +47,7 @@ def group_cities(seq: list) -> list: results.append(temp) # Sort the elements of each group alphabetically. - results: list = ([sorted(list(r)) for r in results]) + results = ([sorted(list(r)) for r in results]) # Sort the groups sort_results(results) return results @@ -60,8 +60,8 @@ def rotate(item: str, element: str) -> bool: :param element: str :return: bool """ - item: str = item.lower() - element: str = element.lower() + item = item.lower() + element = element.lower() i: int = 0 max_i = len(item) * len(item) while i < max_i: diff --git a/kyu_6/rotate_the_letters_of_each_element/test_group_cities.py b/kyu_6/rotate_the_letters_of_each_element/test_group_cities.py index a34f50a4d6a..6eb7b5412d1 100644 --- a/kyu_6/rotate_the_letters_of_each_element/test_group_cities.py +++ b/kyu_6/rotate_the_letters_of_each_element/test_group_cities.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.rotate_the_letters_of_each_element.group_cities import group_cities +from kyu_6.rotate_the_letters_of_each_element.group_cities \ + import group_cities # pylint: disable-msg=R0801 @allure.epic('6 kyu') @@ -24,7 +25,7 @@ 'STRINGS', 'SORTING ALGORITHMS') @allure.link( - url='https://www.codewars.com/kata/5e98712b7de14f0026ef1cc1/train/python', + url='https://www.codewars.com/kata/5e98712b7de14f0026ef1cc1', name='Source/Kata') # pylint: enable-msg=R0801 class GroupCitiesTestCase(unittest.TestCase): @@ -57,7 +58,7 @@ def test_group_cities(self): "will be taken into account for the result, discarding the rest." "

    ") # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( (['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris', 'Okyot'], [['Kyoto', 'Okyot', 'Tokyo'], ['Donlon', 'London'], ['Paris'], ['Rome']]), @@ -77,8 +78,7 @@ def test_group_cities(self): (['Ab', 'Aba', 'A', 'Bbab', 'Baa', 'B', 'Cac', 'A', 'Baa', 'Bbbb', 'Ac', 'Bcbaa', 'Ab'], [['Aba', 'Baa'], ['A'], ['Ab'], ['Ac'], ['B'], ['Bbab'], - ['Bbbb'], ['Bcbaa'], ['Cac']]) - ) + ['Bbbb'], ['Bcbaa'], ['Cac']])) for data in test_data: seq: list = data[0] diff --git a/kyu_6/row_of_the_odd_triangle/README.md b/kyu_6/row_of_the_odd_triangle/README.md index 034c9e86ad1..97aee9cfa7b 100644 --- a/kyu_6/row_of_the_odd_triangle/README.md +++ b/kyu_6/row_of_the_odd_triangle/README.md @@ -21,4 +21,4 @@ odd_row(3) == [7, 9, 11] **Note:** your code should be optimized to handle big inputs. -[Source](https://www.codewars.com/kata/5d5a7525207a674b71aa25b5/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5d5a7525207a674b71aa25b5) \ No newline at end of file diff --git a/kyu_6/row_of_the_odd_triangle/test_odd_row.py b/kyu_6/row_of_the_odd_triangle/test_odd_row.py index f56d927b27d..7fc73c9c772 100644 --- a/kyu_6/row_of_the_odd_triangle/test_odd_row.py +++ b/kyu_6/row_of_the_odd_triangle/test_odd_row.py @@ -22,7 +22,7 @@ @allure.tag('ALGORITHMS', 'PERFORMANCE') @allure.link( - url='https://www.codewars.com/kata/5d5a7525207a674b71aa25b5/train/python', + url='https://www.codewars.com/kata/5d5a7525207a674b71aa25b5', name='Source/Kata') # pylint: enable=R0801 class OddRowTestCase(unittest.TestCase): diff --git a/kyu_6/sort_the_odd/README.md b/kyu_6/sort_the_odd/README.md index 1044ad38fde..2653a5ad0eb 100644 --- a/kyu_6/sort_the_odd/README.md +++ b/kyu_6/sort_the_odd/README.md @@ -12,4 +12,4 @@ Example: sort_array([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4] ``` -[Source](https://www.codewars.com/kata/578aa45ee9fd15ff4600090d/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/578aa45ee9fd15ff4600090d) \ No newline at end of file diff --git a/kyu_6/sort_the_odd/test_sort_array.py b/kyu_6/sort_the_odd/test_sort_array.py index 363eab6938d..4791ffccb1d 100644 --- a/kyu_6/sort_the_odd/test_sort_array.py +++ b/kyu_6/sort_the_odd/test_sort_array.py @@ -21,7 +21,7 @@ @allure.tag('FUNDAMENTALS', 'ARRAYS') @allure.link( - url='https://www.codewars.com/kata/578aa45ee9fd15ff4600090d/train/python', + url='https://www.codewars.com/kata/578aa45ee9fd15ff4600090d', name='Source/Kata') class SortArrayTestCase(unittest.TestCase): """ @@ -67,4 +67,5 @@ def test_sort_array(self): print_log(source_array=source_array, expected=expected, result=actual_result) + self.assertListEqual(expected, actual_result) diff --git a/kyu_6/string_subpattern_recognition_1/README.md b/kyu_6/string_subpattern_recognition_1/README.md index 4e7a5c67a21..4d674be58b2 100644 --- a/kyu_6/string_subpattern_recognition_1/README.md +++ b/kyu_6/string_subpattern_recognition_1/README.md @@ -21,4 +21,4 @@ Strings will never be empty and can be composed of any character (just consider upper- and lowercase letters as different entities) and can be pretty long (keep an eye on performances!). -[Source](https://www.codewars.com/kata/5a49f074b3bfa89b4c00002b/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5a49f074b3bfa89b4c00002b) \ No newline at end of file diff --git a/kyu_6/string_subpattern_recognition_1/test_has_subpattern.py b/kyu_6/string_subpattern_recognition_1/test_has_subpattern.py index 1f7dca56bd7..4a3e2d2d0ac 100644 --- a/kyu_6/string_subpattern_recognition_1/test_has_subpattern.py +++ b/kyu_6/string_subpattern_recognition_1/test_has_subpattern.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.string_subpattern_recognition_1.has_subpattern import has_subpattern +from kyu_6.string_subpattern_recognition_1.has_subpattern \ + import has_subpattern # pylint: disable-msg=R0801 @@ -55,7 +56,7 @@ def test_has_subpattern(self): with allure.step("Pass the string and verify the output"): # pylint: disable-msg=R0801 - test_data = [ + test_data: tuple = ( ("a", False), ("aaaa", True), ("abcd", False), @@ -234,9 +235,9 @@ def test_has_subpattern(self): 'Og8DIxUwpu6u5z0TlmPo9WpIx9sNOMe8bKJPIdmxv22iUvNs5dY5M6J0VK5NNPeFIM5ze2gSDD' 'A5AgJRazkzypfJCXAf3ZTaPQZSmaBUw7pLu0yhXPFNMukrjhOSGMwXnUElhSDpNl30wpmawcCS' 'eYG0kZXuBfwMSExZyTf0ip5ANOgOSoIHN6FnbqntM52X8HjSbxPm4jAo9fBmXkbWSNhfWbLF1O' - 'isf6cbXgHamWcOshCf3H6nqIqI1FVfxaO8warADMpwGgo9BHMvFvr2wc', True) - ] - + 'isf6cbXgHamWcOshCf3H6nqIqI1FVfxaO8warADMpwGgo9BHMvFvr2wc', True)) + # pylint: disable-msg=R0801 for data in test_data: print_log(string=data[0], expected=data[1]) self.assertEqual(data[1], has_subpattern(data[0])) + # pylint: disable-msg=R0801 diff --git a/kyu_6/string_subpattern_recognition_2/README.md b/kyu_6/string_subpattern_recognition_2/README.md index 8d49071c46e..ddb571b7e6e 100644 --- a/kyu_6/string_subpattern_recognition_2/README.md +++ b/kyu_6/string_subpattern_recognition_2/README.md @@ -27,4 +27,4 @@ Strings will never be empty and can be composed of any character (just consider upper- and lowercase letters as different entities) and can be pretty long (keep an eye on performances!). -[Source](https://www.codewars.com/kata/5a4a391ad8e145cdee0000c4/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5a4a391ad8e145cdee0000c4) \ No newline at end of file diff --git a/kyu_6/string_subpattern_recognition_2/test_has_subpattern.py b/kyu_6/string_subpattern_recognition_2/test_has_subpattern.py index 7f82789a630..00b186b4b88 100644 --- a/kyu_6/string_subpattern_recognition_2/test_has_subpattern.py +++ b/kyu_6/string_subpattern_recognition_2/test_has_subpattern.py @@ -58,7 +58,7 @@ def test_has_subpattern(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Pass the string and verify the output"): - test_data = [ + test_data: tuple = ( ("a", False), ("aaaa", True), ("abcd", False), @@ -88,9 +88,9 @@ def test_has_subpattern(self): "ClwmA2bGkHLVayBb5Cayl2m9w4TBgkGbTw0lHB2VG5NnFwyF17Gk" "Tn5TdH7HVnlyvG51do9k35zO4aqmPBTwnXu5wdBvvTPdL715ln4o" "jGVTTlgks119kuCV3Ta5vLa7nqmdolmjPG5wqGynXG2n1XTCbz10" - "BadOFvTbbgHOnywVG50wwNnzObkddNF5BGzobX", True) - ] - + "BadOFvTbbgHOnywVG50wwNnzObkddNF5BGzobX", True)) + # pylint: disable-msg=R0801 for data in test_data: print_log(string=data[0], expected=data[1]) self.assertEqual(data[1], has_subpattern(data[0])) + # pylint: enable-msg=R0801 diff --git a/kyu_6/string_subpattern_recognition_3/README.md b/kyu_6/string_subpattern_recognition_3/README.md index fb9475e8de7..0031035fcf4 100644 --- a/kyu_6/string_subpattern_recognition_3/README.md +++ b/kyu_6/string_subpattern_recognition_3/README.md @@ -23,4 +23,4 @@ repeated only once and thus equalling the original input string). > has_subpattern("bbabbaaabbaaaabb") == "ab" #same as above, just shuffled -[Source](https://www.codewars.com/kata/5a4a2973d8e14586c700000a/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5a4a2973d8e14586c700000a) \ No newline at end of file diff --git a/kyu_6/string_subpattern_recognition_3/test_has_subpattern.py b/kyu_6/string_subpattern_recognition_3/test_has_subpattern.py index f68c80c8c36..28d6c90d817 100644 --- a/kyu_6/string_subpattern_recognition_3/test_has_subpattern.py +++ b/kyu_6/string_subpattern_recognition_3/test_has_subpattern.py @@ -10,7 +10,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.string_subpattern_recognition_3.has_subpattern import has_subpattern +from kyu_6.string_subpattern_recognition_3.has_subpattern \ + import has_subpattern # pylint: disable-msg=R0801 @@ -26,7 +27,7 @@ 'DECLARATIVE PROGRAMMING', 'ADVANCED LANGUAGE FEATURES') @allure.link( - url='https://www.codewars.com/kata/5a4a2973d8e14586c700000a/train/python', + url='https://www.codewars.com/kata/5a4a2973d8e14586c700000a', name='Source/Kata') # pylint: enable-msg=R0801 class HasSubpatternTestCase(unittest.TestCase): @@ -56,7 +57,7 @@ def test_has_subpattern(self): # pylint: enable-msg=R0801 # pylint: disable-msg=C0301 with allure.step("Pass the string and verify the output"): - data_set = [ + data_set: tuple = ( ('sZZpCWRNzSfvfZy5CMsRbdHeb85L3DmMB7dLMIM33pylSW6hHXp' 'dthSmvynxF7cSUtSVShx8vwSYaa7dg4jyCzHzJqnYHRGD0sTg5z' 'XOB42f9fuo47NhwV7fVZkzCyIfVzUvb90M5FOx3xXPo3fqFOqZk' @@ -154,8 +155,7 @@ def test_has_subpattern(self): 'yte9H0c8hOcsjLNyX0wMcch8L228E4e0i4Xf3cgRZmZj08j8ggg' 'xsX0gNRs24OLRwEE2lOM3hL0TZEEFh2c4i0N68xRR4iRTe2m2tj' 'N48JeERERix6gyg', - '0022344689EEFHJLLMNORRTXYZccdefggghiijlmstwxy'), - ] + '0022344689EEFHJLLMNORRTXYZccdefggghiijlmstwxy')) # pylint: enable-msg=C0301 for data in data_set: result = has_subpattern(data[0]) diff --git a/kyu_6/string_transformer/README.md b/kyu_6/string_transformer/README.md index 9d8a854f6a9..5ba97a4a83c 100644 --- a/kyu_6/string_transformer/README.md +++ b/kyu_6/string_transformer/README.md @@ -14,4 +14,4 @@ Given a string, return a new string that has transformed based on the input: You may assume the input only contain English alphabet and spaces. -[Source](https://www.codewars.com/kata/5878520d52628a092f0002d0/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5878520d52628a092f0002d0) \ No newline at end of file diff --git a/kyu_6/string_transformer/test_string_transformer.py b/kyu_6/string_transformer/test_string_transformer.py index 1a6ccf88ad4..4a5fd3fb318 100644 --- a/kyu_6/string_transformer/test_string_transformer.py +++ b/kyu_6/string_transformer/test_string_transformer.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.string_transformer.string_transformer import string_transformer +from kyu_6.string_transformer.string_transformer \ + import string_transformer @allure.epic('6 kyu') @@ -20,12 +21,13 @@ @allure.story('String transformer') @allure.tag('FUNDAMENTALS') @allure.link( - url='https://www.codewars.com/kata/5878520d52628a092f0002d0/train/python', + url='https://www.codewars.com/kata/5878520d52628a092f0002d0', name='Source/Kata') class StringTransformerTestCase(unittest.TestCase): """ Testing string_transformer function """ + def test_string_transformer(self): """ Testing string_transformer function @@ -41,16 +43,18 @@ def test_string_transformer(self): :return: """ + # pylint: disable-msg=R0801 allure.dynamic.title("Testing string_transformer function") allure.dynamic.severity(allure.severity_level.NORMAL) - allure.dynamic.description_html('

    Codewars badge:

    ' - '' - '

    Test Description:

    ' - "

    ") - + allure.dynamic.description_html( + '

    Codewars badge:

    ' + '' + '

    Test Description:

    ' + "

    ") + # pylint: enable-msg=R0801 with allure.step("Enter test string and verify the output"): - test_data = [ + test_data: tuple = ( ("Example string", "STRING eXAMPLE"), ("Example Input", "iNPUT eXAMPLE"), ("To be OR not to be That is the Question", @@ -84,7 +88,7 @@ def test_string_transformer(self): ("UOtfi erH kCk KXzg Io Y I TYAf " "EGXVSvASIyJ p Zf p kV g RI V", "v ri G Kv P zF P egxvsVasiYj tyaF " - "i y iO kxZG KcK ERh uoTFI")] + "i y iO kxZG KcK ERh uoTFI")) for s, expected in test_data: print_log(s=s, expected=expected) diff --git a/kyu_6/sum_of_digits_digital_root/README.md b/kyu_6/sum_of_digits_digital_root/README.md index b07983c4af6..1668bf5c6f1 100644 --- a/kyu_6/sum_of_digits_digital_root/README.md +++ b/kyu_6/sum_of_digits_digital_root/README.md @@ -35,4 +35,4 @@ digital_root(493193) => 2 ``` -[Source](https://www.codewars.com/kata/541c8630095125aba6000c00/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/541c8630095125aba6000c00) \ No newline at end of file diff --git a/kyu_6/sum_of_digits_digital_root/test_digital_root.py b/kyu_6/sum_of_digits_digital_root/test_digital_root.py index 2c3dcd75b85..2c99719aec7 100644 --- a/kyu_6/sum_of_digits_digital_root/test_digital_root.py +++ b/kyu_6/sum_of_digits_digital_root/test_digital_root.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_6.sum_of_digits_digital_root.digital_root import digital_root +from kyu_6.sum_of_digits_digital_root.digital_root \ + import digital_root @allure.epic('6 kyu') @@ -23,7 +24,7 @@ 'NUMBERS', 'ARITHMETIC') @allure.link( - url='https://www.codewars.com/kata/541c8630095125aba6000c00/train/python', + url='https://www.codewars.com/kata/541c8630095125aba6000c00', name='Source/Kata') class DigitalRootTestCase(unittest.TestCase): """ @@ -51,12 +52,12 @@ def test_digital_root(self): "

    ") # pylint: enable-msg=R0801 with allure.step("Enter a number and verify the output"): - test_data = [ + test_data: tuple = ( (16, 7), (456, 6), (942, 6), (132189, 6), - (493193, 2)] + (493193, 2)) for n, expected in test_data: print_log(n=n, expected=expected) diff --git a/kyu_6/unique_in_order/README.md b/kyu_6/unique_in_order/README.md index fe516d968b6..fd015a86d27 100644 --- a/kyu_6/unique_in_order/README.md +++ b/kyu_6/unique_in_order/README.md @@ -13,4 +13,4 @@ order of elements. > > unique_in_order(`[1,2,2,3,3]`) == `[1,2,3]` -[Source](https://www.codewars.com/kata/54e6533c92449cc251001667/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/54e6533c92449cc251001667) \ No newline at end of file diff --git a/kyu_6/unique_in_order/test_unique_in_order.py b/kyu_6/unique_in_order/test_unique_in_order.py index 90076cc682f..07583152f78 100644 --- a/kyu_6/unique_in_order/test_unique_in_order.py +++ b/kyu_6/unique_in_order/test_unique_in_order.py @@ -48,7 +48,7 @@ def test_unique_in_order(self): # pylint: enable-msg=R0801 # pylint: disable=line-too-long with allure.step("Pass test data and verify the output"): - data = [ + data: tuple = ( ('AAAABBBCCDAABBB', ['A', 'B', 'C', 'D', 'A', 'B'], 'Should reduce duplicates'), @@ -84,7 +84,7 @@ def test_unique_in_order(self): -1682985580, -308066619, 807682642, 1886853360, 1165912447, -1816272783, 2088008817, -2119157678, 1041981535, 661938680, 438934930, 1442648715, 468638621, 258893461, -46757153, 1997749513, 78748495, 1555244045, 1506976994, -804276632, -367750677, -733550250], - 'Should work with randomly generated sequence')] + 'Should work with randomly generated sequence')) # pylint: enable=line-too-long for test_data, expected, msg in data: print_log(iterable=test_data, expected=expected, msg=msg) diff --git a/kyu_6/vasya_clerk/README.md b/kyu_6/vasya_clerk/README.md index 874f5d05715..e3bfbcdcc5a 100644 --- a/kyu_6/vasya_clerk/README.md +++ b/kyu_6/vasya_clerk/README.md @@ -24,4 +24,4 @@ tickets([25, 25, 50, 50, 100]) # => NO. Vasya will not have the right bills to g ``` -[Source](https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8) \ No newline at end of file diff --git a/kyu_6/vasya_clerk/test_tickets.py b/kyu_6/vasya_clerk/test_tickets.py index e55d51d56aa..c6601ead184 100644 --- a/kyu_6/vasya_clerk/test_tickets.py +++ b/kyu_6/vasya_clerk/test_tickets.py @@ -24,7 +24,7 @@ 'NUMBERS', 'GAMES') @allure.link( - url='https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8/train/python', + url='https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8', name='Source/Kata') class TicketsTestCase(unittest.TestCase): """ @@ -88,6 +88,5 @@ def test_tickets(self): 'N/A')) for arr, expected, msg in test_data: - print_log(people=arr, expected=expected, msg=msg) self.assertEqual(expected, tickets(arr), msg) diff --git a/kyu_6/who_likes_it/README.md b/kyu_6/who_likes_it/README.md index 094daf92174..211ca40ec4e 100644 --- a/kyu_6/who_likes_it/README.md +++ b/kyu_6/who_likes_it/README.md @@ -19,4 +19,4 @@ likes ["Alex", "Jacob", "Mark", "Max"] // must be "Alex, Jacob and 2 others like For 4 or more names, the number in and 2 others simply increases. -[Source](https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/5266876b8f4bf2da9b000362) \ No newline at end of file diff --git a/kyu_6/who_likes_it/test_likes_function.py b/kyu_6/who_likes_it/test_likes_function.py index fb8de7c6399..8e94829d92f 100644 --- a/kyu_6/who_likes_it/test_likes_function.py +++ b/kyu_6/who_likes_it/test_likes_function.py @@ -24,7 +24,7 @@ 'ALGORITHMS', 'STRINGS') @allure.link( - url='https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/python', + url='https://www.codewars.com/kata/5266876b8f4bf2da9b000362', name='Source/Kata') # pylint: enable=R0801 class LikesTestCase(unittest.TestCase): diff --git a/kyu_6/your_order_please/README.md b/kyu_6/your_order_please/README.md index 869d80c39f1..32b0b767349 100644 --- a/kyu_6/your_order_please/README.md +++ b/kyu_6/your_order_please/README.md @@ -17,4 +17,4 @@ in the input String will only contain valid consecutive numbers. "" --> "" ``` -[Source](https://www.codewars.com/kata/55c45be3b2079eccff00010f/train/python) \ No newline at end of file +[Source](https://www.codewars.com/kata/55c45be3b2079eccff00010f) \ No newline at end of file diff --git a/kyu_6/your_order_please/test_order.py b/kyu_6/your_order_please/test_order.py index 616f95cbff7..2501ff0292f 100644 --- a/kyu_6/your_order_please/test_order.py +++ b/kyu_6/your_order_please/test_order.py @@ -21,7 +21,7 @@ @allure.tag('FUNDAMENTALS', 'STRINGS') @allure.link( - url='https://www.codewars.com/kata/55c45be3b2079eccff00010f/train/python', + url='https://www.codewars.com/kata/55c45be3b2079eccff00010f', name='Source/Kata') class OrderTestCase(unittest.TestCase): """ @@ -62,13 +62,12 @@ def test_order(self): 'The words in the input String will only contain valid consecutive ' 'numbers.

    ') # pylint: enable-msg=R0801 - test_data = ( + test_data: tuple = ( ("is2 Thi1s T4est 3a", "Thi1s is2 3a T4est"), ("4of Fo1r pe6ople g3ood th5e the2", "Fo1r the2 g3ood 4of th5e pe6ople"), - ("", ""), - ) + ("", "")) for (sentence, expected) in test_data: actual_result: str = order(sentence) diff --git a/kyu_7/basic_math_add_or_subtract/calculate.py b/kyu_7/basic_math_add_or_subtract/calculate.py index e62530284b5..a94d40cc896 100644 --- a/kyu_7/basic_math_add_or_subtract/calculate.py +++ b/kyu_7/basic_math_add_or_subtract/calculate.py @@ -15,7 +15,7 @@ def calculate(s: str) -> str: :param s: str :return: str """ - s: str = s.lower() + s = s.lower() for key, item in CONVERSION.items(): if key in s: s = s.replace(key, item) diff --git a/kyu_7/beginner_series_sum_of_numbers/test_sum_of_numbers.py b/kyu_7/beginner_series_sum_of_numbers/test_sum_of_numbers.py index 033a9d9d70f..9ed4aace96f 100644 --- a/kyu_7/beginner_series_sum_of_numbers/test_sum_of_numbers.py +++ b/kyu_7/beginner_series_sum_of_numbers/test_sum_of_numbers.py @@ -9,7 +9,8 @@ import unittest import allure from utils.log_func import print_log -from kyu_7.beginner_series_sum_of_numbers.sum_of_numbers import get_sum +from kyu_7.beginner_series_sum_of_numbers.sum_of_numbers \ + import get_sum # pylint: disable-msg=R0801 @@ -73,13 +74,13 @@ def test_get_sum_positive_numbers(self): with allure.step("Assert the result"): a = expected = 1 - b: int = 0 + b = 0 print_log(a=a, b=b, expected=expected) self.assertEqual(get_sum(a, b), expected) with allure.step("Assert the result"): - a: int = 1 - b: int = 2 + a = 1 + b = 2 expected = a + b print_log(a=a, b=b, expected=expected) self.assertEqual(get_sum(a, b), expected) @@ -106,14 +107,14 @@ def test_get_sum_negative_numbers(self): self.assertEqual(get_sum(a, b), expected) with allure.step("Assert the result"): - a: int = -1 - b: int = 0 - expected: int = a + b + a = -1 + b = 0 + expected = a + b print_log(a=a, b=b, expected=expected) self.assertEqual(get_sum(a, b), expected) with allure.step("Assert the result"): - a: int = -1 + a = -1 b = expected = 2 print_log(a=a, b=b, expected=expected) self.assertEqual(get_sum(a, b), expected) diff --git a/kyu_7/easy_line/easyline.py b/kyu_7/easy_line/easyline.py index f9484f09368..bbfdf652a34 100644 --- a/kyu_7/easy_line/easyline.py +++ b/kyu_7/easy_line/easyline.py @@ -7,7 +7,7 @@ import math -def easy_line(n: int) -> (int, ValueError): +def easy_line(n: int): """ The function will take n (with: n>= 0) as parameter and will return the sum of the squares of the binomial diff --git a/kyu_7/formatting_decimal_places_1/two_decimal_places.py b/kyu_7/formatting_decimal_places_1/two_decimal_places.py index 79892360753..f01b102d8b1 100644 --- a/kyu_7/formatting_decimal_places_1/two_decimal_places.py +++ b/kyu_7/formatting_decimal_places_1/two_decimal_places.py @@ -19,5 +19,5 @@ def two_decimal_places(number) -> float: :param number: :return: float """ - number: str = str(number) - return float(number[0:number.index('.') + 3]) + number_str: str = str(number) + return float(number_str[0:number_str.index('.') + 3]) diff --git a/kyu_7/powers_of_3/test_largest_power.py b/kyu_7/powers_of_3/test_largest_power.py index ad3448b8d7c..557adfc8531 100644 --- a/kyu_7/powers_of_3/test_largest_power.py +++ b/kyu_7/powers_of_3/test_largest_power.py @@ -58,7 +58,7 @@ def test_largest_power(self): self.assertEqual(largest_power(n), expected) with allure.step("Pass an integer and verify the output"): - n: int = 4 - expected: int = 1 + n = 4 + expected = 1 print_log(N=n, expected=expected) self.assertEqual(largest_power(n), expected) diff --git a/kyu_7/significant_figures/number_of_sigfigs.py b/kyu_7/significant_figures/number_of_sigfigs.py index 3984b5dfc49..e87be25ad9c 100644 --- a/kyu_7/significant_figures/number_of_sigfigs.py +++ b/kyu_7/significant_figures/number_of_sigfigs.py @@ -12,7 +12,7 @@ def number_of_sigfigs(number: str) -> int: :param number: :return: """ - number: str = normalize_string(number) + number = normalize_string(number) if number == '0': return 0 if number == '0.0': diff --git a/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py b/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py index 3c936a625d6..7de7af745e5 100644 --- a/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py +++ b/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py @@ -56,8 +56,8 @@ def test_sum_triangular_numbers_negative_numbers(self): self.assertEqual(sum_triangular_numbers(n), expected) with allure.step("Enter negative number and verify the output"): - n: int = -971 - expected: int = 0 + n = -971 + expected = 0 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected) @@ -109,8 +109,8 @@ def test_sum_triangular_numbers_positive_numbers(self): with allure.step("Enter a positive number as an input " "and verify the output"): - n: int = 34 - expected: int = 7140 + n = 34 + expected = 7140 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected) diff --git a/kyu_7/the_first_non_repeated_character_in_string/first_non_repeated.py b/kyu_7/the_first_non_repeated_character_in_string/first_non_repeated.py index d9fe464b14e..29717ae3203 100644 --- a/kyu_7/the_first_non_repeated_character_in_string/first_non_repeated.py +++ b/kyu_7/the_first_non_repeated_character_in_string/first_non_repeated.py @@ -5,7 +5,7 @@ """ -def first_non_repeated(s: str) -> (str, None): +def first_non_repeated(s: str) -> str | None: """ You need to write a function, that returns the first non-repeated character in the given string. diff --git a/kyu_7/vaporcode/test_vaporcode.py b/kyu_7/vaporcode/test_vaporcode.py index 2b3414cf553..474fe8360f6 100644 --- a/kyu_7/vaporcode/test_vaporcode.py +++ b/kyu_7/vaporcode/test_vaporcode.py @@ -54,23 +54,23 @@ def test_vaporcode(self): with allure.step("Enter string with special " "chars and verify the output"): - string: str = "Why isn't my code working?" - expected: str = "W H Y I S N ' T M Y " \ - "C O D E W O R K I N G ?" + string = "Why isn't my code working?" + expected = "W H Y I S N ' T M Y " \ + "C O D E W O R K I N G ?" print_log(s=string, expected=expected) self.assertEqual(vaporcode(string), expected) with allure.step("Enter crazy string and verify the output"): - string: str = " ; FUV! qd vz Xy-b pM.!:F lEqRLY,p RGS:;Rh Z " - expected: str = "; F U V ! Q D V Z X Y - B P " \ - "M . ! : F L E Q R L Y , P R G " \ - "S : ; R H Z" + string = " ; FUV! qd vz Xy-b pM.!:F lEqRLY,p RGS:;Rh Z " + expected = "; F U V ! Q D V Z X Y - B P " \ + "M . ! : F L E Q R L Y , P R G " \ + "S : ; R H Z" print_log(s=string, expected=expected) self.assertEqual(vaporcode(string), expected) with allure.step("Enter string with chars" "only and verify the output"): - string: str = "blah" - expected: str = "B L A H" + string = "blah" + expected = "B L A H" print_log(s=string, expected=expected) self.assertEqual(vaporcode(string), expected) diff --git a/kyu_8/check_the_exam/check_exam.py b/kyu_8/check_the_exam/check_exam.py index 11ff7f7b9b1..319bf5d155f 100644 --- a/kyu_8/check_the_exam/check_exam.py +++ b/kyu_8/check_the_exam/check_exam.py @@ -5,7 +5,7 @@ """ -def check_exam(arr1, arr2) -> int: +def check_exam(arr1: list, arr2: list) -> int: """ The first input array contains the correct answers to an exam, like ["a", "a", "b", "d"]. The second @@ -18,9 +18,9 @@ def check_exam(arr1, arr2) -> int: If the score < 0, return 0. - :param arr1: - :param arr2: - :return: + :param arr1: list + :param arr2: list + :return: int """ results: list = [] for char in zip(arr1, arr2): @@ -30,7 +30,7 @@ def check_exam(arr1, arr2) -> int: return 0 if total < 0 else total -def char_processor(char: str, results: list) -> None: +def char_processor(char: tuple, results: list) -> None: """ Processing chars based on specified rule :param char: str 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 b625b6465c6..e88d5a1c966 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 @@ -5,7 +5,7 @@ """ -def first_non_consecutive(arr: list) -> int: +def first_non_consecutive(arr: list) -> int | None: """ Find the first element of an array that is not consecutive. 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 a2d5135102a..fe89221e5a2 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 @@ -48,8 +48,8 @@ def test_first_non_consecutive_none(self): "

    ") # pylint: enable=R0801 with allure.step("Pass a list with no non consecutive numbers"): - lst = [1, 2, 3, 4, 5, 6, 7, 8] - expected = None + lst: list = [1, 2, 3, 4, 5, 6, 7, 8] + expected: None = None print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) @@ -84,33 +84,33 @@ def test_first_non_consecutive_large_list(self): 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119] - expected = None + expected: None = None print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a large list with no non consecutive numbers"): - lst: list = [98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, - 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158] + lst = [98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158] expected = None print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a large list with non consecutive number"): - lst: list = [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149] - expected: int = 101 - print_log(list=lst, expected=expected) - self.assertEqual(first_non_consecutive(lst), expected) + lst = [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149] + expected_int: int = 101 + print_log(list=lst, expected=expected_int) + self.assertEqual(first_non_consecutive(lst), expected_int) def test_first_non_consecutive_positive(self): """ @@ -136,35 +136,35 @@ def test_first_non_consecutive_positive(self): self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a list with positive non consecutive number"): - lst: list = [4, 6, 7, 8, 9, 11] - expected: int = 6 + lst = [4, 6, 7, 8, 9, 11] + expected = 6 print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a list with positive non consecutive number"): - lst: list = [4, 5, 6, 7, 8, 9, 11] - expected: int = 11 + lst = [4, 5, 6, 7, 8, 9, 11] + expected = 11 print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a list with positive non consecutive number"): - lst: list = [-3, -2, 0, 1] - expected: int = 0 + lst = [-3, -2, 0, 1] + expected = 0 print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a list with positive non consecutive number"): - lst: list = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 25, 26, 27] - expected: int = 25 + lst = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 25, 26, 27] + expected = 25 print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) with allure.step("Pass a list with positive non consecutive number"): - lst: list = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, - 40, 41, 42, 43, 44, 45] - expected: int = 39 + lst = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, + 40, 41, 42, 43, 44, 45] + expected = 39 print_log(list=lst, expected=expected) self.assertEqual(first_non_consecutive(lst), expected) 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 3c7127108ba..a69045f494d 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 @@ -61,10 +61,10 @@ def test_goals(self): expected) with allure.step("Test with positive integers"): - la_liga: int = 5 - copa_del_rey: int = 10 - champions: int = 2 - expected: int = 17 + la_liga = 5 + copa_del_rey = 10 + champions = 2 + expected = 17 print_log(la_liga=la_liga, copa_del_rey=copa_del_rey, diff --git a/kyu_8/grasshopper_personalized_message/README.md b/kyu_8/grasshopper_personalized_message/README.md index cd909c5fdb5..f85354f795d 100644 --- a/kyu_8/grasshopper_personalized_message/README.md +++ b/kyu_8/grasshopper_personalized_message/README.md @@ -5,9 +5,9 @@ This function takes two parameters: name and owner. ## Use conditionals to return the proper message -| **case** | **return** | +| **case** | **return** | |-------------------------|:-------------------------:| -| *name equals owner* | 'Hello boss' | -| *otherwise* | 'Hello guest' | +| *name equals owner* | 'Hello boss' | +| *otherwise* | 'Hello guest' | [Source](https://www.codewars.com/kata/5772da22b89313a4d50012f7) 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 3a45ebd45b9..c7ebc2db024 100644 --- a/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py +++ b/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py @@ -58,8 +58,8 @@ def test_greet(self): # otherwise with allure.step("Test name not equals owner"): - name: str = 'Greg' - owner: str = 'Daniel' - expected: str = 'Hello guest' + name = 'Greg' + owner = 'Daniel' + expected = 'Hello guest' print_log(name=name, owner=owner, expected=expected) self.assertEqual(greet(name, owner), expected) 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 83ef8d2a29e..eb75b23032f 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 @@ -59,9 +59,9 @@ def test_period_is_late_positive(self): self.assertTrue(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 7, 12) - today: date = date(2016, 8, 10) - cycle_length: int = 28 + last = date(2016, 7, 12) + today = date(2016, 8, 10) + cycle_length = 28 print_log(last=last, today=today, @@ -71,9 +71,9 @@ def test_period_is_late_positive(self): self.assertTrue(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 7, 1) - today: date = date(2016, 8, 1) - cycle_length: int = 30 + last = date(2016, 7, 1) + today = date(2016, 8, 1) + cycle_length = 30 print_log(last=last, today=today, @@ -83,9 +83,9 @@ def test_period_is_late_positive(self): self.assertTrue(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 1, 1) - today: date = date(2016, 2, 1) - cycle_length: int = 30 + last = date(2016, 1, 1) + today = date(2016, 2, 1) + cycle_length = 30 print_log(last=last, today=today, @@ -122,9 +122,9 @@ def test_period_is_late_negative(self): self.assertFalse(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 6, 13) - today: date = date(2016, 7, 16) - cycle_length: int = 35 + last = date(2016, 6, 13) + today = date(2016, 7, 16) + cycle_length = 35 print_log(last=last, today=today, @@ -134,9 +134,9 @@ def test_period_is_late_negative(self): self.assertFalse(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 6, 13) - today: date = date(2016, 6, 29) - cycle_length: int = 28 + last = date(2016, 6, 13) + today = date(2016, 6, 29) + cycle_length = 28 print_log(last=last, today=today, @@ -146,9 +146,9 @@ def test_period_is_late_negative(self): self.assertFalse(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 7, 12) - today: date = date(2016, 8, 9) - cycle_length: int = 28 + last = date(2016, 7, 12) + today = date(2016, 8, 9) + cycle_length = 28 print_log(last=last, today=today, @@ -158,9 +158,9 @@ def test_period_is_late_negative(self): self.assertFalse(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 6, 1) - today: date = date(2016, 6, 30) - cycle_length: int = 30 + last = date(2016, 6, 1) + today = date(2016, 6, 30) + cycle_length = 30 print_log(last=last, today=today, @@ -170,9 +170,9 @@ def test_period_is_late_negative(self): self.assertFalse(period_is_late(last, today, cycle_length)) with allure.step("Pass last, today and period length"): - last: date = date(2016, 1, 1) - today: date = date(2016, 1, 31) - cycle_length: int = 30 + last = date(2016, 1, 1) + today = date(2016, 1, 31) + cycle_length = 30 print_log(last=last, today=today, diff --git a/kyu_8/logical_calculator/test_logical_calculator.py b/kyu_8/logical_calculator/test_logical_calculator.py index 95a37215882..7f4e11cc220 100644 --- a/kyu_8/logical_calculator/test_logical_calculator.py +++ b/kyu_8/logical_calculator/test_logical_calculator.py @@ -62,36 +62,36 @@ def test_logical_calc_and(self): self.assertEqual(logical_calc(lst, operator), expected) with allure.step("Pass an array with 3 members (negative)"): - lst: list = [True, True, False] - operator: str = 'AND' - expected: bool = False + lst = [True, True, False] + operator = 'AND' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step("Pass an array with 3 members (negative)"): - lst: list = [False, False, False] - operator: str = 'AND' - expected: bool = False + lst = [False, False, False] + operator = 'AND' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step("Pass an array with 3 members (positive)"): - lst: list = [True, True, True] - operator: str = 'AND' - expected: bool = True + lst = [True, True, True] + operator = 'AND' + expected = True print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step("Pass large array (negative)"): - lst: list = [False, False, False, False, True, True, False, - True, True, False, False, True, True, False, - False, False, False, True, True, False, True, - False, False, True, True, True, False, True, - True, False, False, False, False, False, False, - True, True, True, True, False, True, True, False, - True, True, False, False, True, False, False] - operator: str = 'AND' - expected: bool = False + lst = [False, False, False, False, True, True, False, + True, True, False, False, True, True, False, + False, False, False, True, True, False, True, + False, False, True, True, True, False, True, + True, False, False, False, False, False, False, + True, True, True, True, False, True, True, False, + True, True, False, False, True, False, False] + operator = 'AND' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) @@ -127,29 +127,29 @@ def test_logical_calc_or(self): self.assertEqual(logical_calc(lst, operator), expected) with allure.step('Pass an array with 3 members (positive)'): - lst: list = [True, True, False] - operator: str = 'OR' - expected: bool = True + lst = [True, True, False] + operator = 'OR' + expected = True print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step('Pass an array with 3 members (negative)'): - lst: list = [False, False, False] - operator: str = 'OR' - expected: bool = False + lst = [False, False, False] + operator = 'OR' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step('Pass large array (positive)'): - lst: list = [False, True, True, False, False, False, True, False, - False, False, False, True, True, False, False, False, - True, False, False, True, True, True, True, True, - False, True, True, True, False, True, False, False, - True, True, True, True, True, True, False, True, - False, True, False, True, False, True, False, True, - True, True] - operator: str = 'OR' - expected: bool = True + lst = [False, True, True, False, False, False, True, False, + False, False, False, True, True, False, False, False, + True, False, False, True, True, True, True, True, + False, True, True, True, False, True, False, False, + True, True, True, True, True, True, False, True, + False, True, False, True, False, True, False, True, + True, True] + operator = 'OR' + expected = True print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) @@ -183,43 +183,43 @@ def test_logical_calc_xor(self): self.assertEqual(logical_calc(lst, operator), expected) with allure.step('Pass an array with 3 members (negative)'): - lst: list = [True, True, False] - operator: str = 'XOR' - expected: bool = False + lst = [True, True, False] + operator = 'XOR' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(logical_calc(lst, operator), expected) with allure.step('Pass medium size array'): - lst: list = [False, False, True, True, False, - False, False, False, True] - operator: str = 'XOR' - expected: bool = True + lst = [False, False, True, True, False, + False, False, False, True] + operator = 'XOR' + expected = True print_log(list=lst, operator=operator, expected=expected) self.assertEqual(expected, logical_calc(lst, operator)) with allure.step('Pass large size array #1'): - lst: list = [False, False, True, False, False, True, True, - True, False, False, True, False, False, False, - False, True, False, True, False, False, True, - False, False, True, True, True, False, False, - False, False, True, False, False, False, False, - False, True, False, False, False, True, True, - False, True, False, True, False, False, True, - False] - operator: str = 'XOR' - expected: bool = False + lst = [False, False, True, False, False, True, True, + True, False, False, True, False, False, False, + False, True, False, True, False, False, True, + False, False, True, True, True, False, False, + False, False, True, False, False, False, False, + False, True, False, False, False, True, True, + False, True, False, True, False, False, True, + False] + operator = 'XOR' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(expected, logical_calc(lst, operator)) with allure.step('Pass large size array #2'): - lst: list = [True, True, False, False, False, True, True, False, - False, True, False, False, True, False, False, True, - True, True, True, True, True, False, False, False, - False, True, True, False, False, True, True, True, - True, False, True, True, False, False, False, True, - False, True, False, True, False, False, True, False, - True, True] - operator: str = 'XOR' - expected: bool = False + lst = [True, True, False, False, False, True, True, False, + False, True, False, False, True, False, False, True, + True, True, True, True, True, False, False, False, + False, True, True, False, False, True, True, True, + True, False, True, True, False, False, False, True, + False, True, False, True, False, False, True, False, + True, True] + operator = 'XOR' + expected = False print_log(list=lst, operator=operator, expected=expected) self.assertEqual(expected, logical_calc(lst, operator)) 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 c70da344b88..104e80bb659 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 @@ -56,25 +56,25 @@ def test_remove_char(self): self.assertEqual(remove_char(string), expected) with allure.step("Pass 'country' string and verify the output"): - string: str = 'country' - expected: str = 'ountr' + string = 'country' + expected = 'ountr' print_log(string=string, expected=expected) self.assertEqual(remove_char(string), expected) with allure.step("Pass 'person' string and verify the output"): - string: str = 'person' - expected: str = 'erso' + string = 'person' + expected = 'erso' print_log(string=string, expected=expected) self.assertEqual(remove_char(string), expected) with allure.step("Pass 'place' string and verify the output"): - string: str = 'place' - expected: str = 'lac' + string = 'place' + expected = 'lac' print_log(string=string, expected=expected) self.assertEqual(remove_char(string), expected) with allure.step("Pass 'ok' string and verify the output"): - string: str = 'ok' - expected: str = '' + string = 'ok' + expected = '' print_log(string=string, expected=expected) self.assertEqual(remove_char(string), expected) 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 cc68b1e5a45..a2f9bbe5b8b 100644 --- a/kyu_8/remove_string_spaces/test_remove_string_spaces.py +++ b/kyu_8/remove_string_spaces/test_remove_string_spaces.py @@ -58,28 +58,28 @@ def test_something(self): with allure.step("Pass string with spaces " "and verify the result"): - string: str = '8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd' - expected: str = '88Bifk8hB8BB8BBBB888chl8BhBfd' + string = '8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd' + expected = '88Bifk8hB8BB8BBBB888chl8BhBfd' print_log(string=string, expected=expected) self.assertEqual(no_space(string), expected) with allure.step("Pass string with spaces " "and verify the result"): - string: str = '8aaaaa dddd r ' - expected: str = '8aaaaaddddr' + string = '8aaaaa dddd r ' + expected = '8aaaaaddddr' print_log(string=string, expected=expected) self.assertEqual(no_space(string), expected) with allure.step("Pass string with spaces " "and verify the result"): - string: str = 'jfBm gk lf8hg 88lbe8 ' - expected: str = 'jfBmgklf8hg88lbe8' + string = 'jfBm gk lf8hg 88lbe8 ' + expected = 'jfBmgklf8hg88lbe8' print_log(string=string, expected=expected) self.assertEqual(no_space(string), expected) with allure.step("Pass string with spaces " "and verify the result"): - string: str = '8j aam' - expected: str = '8jaam' + string = '8j aam' + expected = '8jaam' print_log(string=string, expected=expected) self.assertEqual(no_space(string), expected) diff --git a/kyu_8/reversed_strings/test_reversed_strings.py b/kyu_8/reversed_strings/test_reversed_strings.py index cd247ee9111..53188413bf7 100644 --- a/kyu_8/reversed_strings/test_reversed_strings.py +++ b/kyu_8/reversed_strings/test_reversed_strings.py @@ -94,7 +94,7 @@ def test_reversed_strings(self): self.assertEqual(solution(string), expected) with allure.step("Pass regular string and verify the output"): - string: str = 'hello' - expected: str = 'olleh' + string = 'hello' + expected = 'olleh' print_log(string=string, expected=expected) self.assertEqual(solution(string), expected) 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 fa99e3e1f8d..90d3dc07ff7 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 @@ -62,7 +62,7 @@ def test_get_size(self): with allure.step("Pass w, h, and d values and verify the result"): w, h, d = 1, 1, 1 - expected: list = [6, 1] + expected = [6, 1] print_log(w=w, h=h, @@ -74,7 +74,7 @@ def test_get_size(self): with allure.step("Pass w, h, and d values and verify the result"): w, h, d = 1, 2, 1 - expected: list = [10, 2] + expected = [10, 2] print_log(w=w, h=h, @@ -86,7 +86,7 @@ def test_get_size(self): with allure.step("Pass w, h, and d values and verify the result"): w, h, d = 1, 2, 2 - expected: list = [16, 4] + expected = [16, 4] print_log(w=w, h=h, @@ -98,7 +98,7 @@ def test_get_size(self): with allure.step("Pass w, h, and d values and verify the result"): w, h, d = 10, 10, 10 - expected: list = [600, 1000] + expected = [600, 1000] print_log(w=w, h=h, 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 e5ba0eefc60..f236d17e6bd 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 @@ -60,9 +60,9 @@ def test_move(self): self.assertEqual(move(position, roll), expected) with allure.step("Test start position even number"): - position: int = 3 - roll: int = 6 - expected: int = 15 + position = 3 + roll = 6 + expected = 15 print_log(position=position, roll=roll, @@ -70,9 +70,9 @@ def test_move(self): self.assertEqual(move(position, roll), expected) with allure.step("Test start position odd number"): - position: int = 2 - roll: int = 5 - expected: int = 12 + position = 2 + roll = 5 + expected = 12 print_log(position=position, roll=roll, 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 368896ae934..c1cceafebcc 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 @@ -58,9 +58,9 @@ def test_other_angle(self): self.assertEqual(other_angle(a, b), expected) with allure.step("Enter values of two angles and return the 3rd"): - a: int = 60 - b: int = 60 - expected: int = 60 + a = 60 + b = 60 + expected = 60 print_log(a=a, b=b, @@ -70,9 +70,9 @@ def test_other_angle(self): self.assertEqual(other_angle(60, 60), 60) with allure.step("Enter values of two angles and return the 3rd"): - a: int = 43 - b: int = 78 - expected: int = 59 + a = 43 + b = 78 + expected = 59 print_log(a=a, b=b, @@ -81,9 +81,9 @@ def test_other_angle(self): self.assertEqual(other_angle(a, b), expected) with allure.step("Enter values of two angles and return the 3rd"): - a: int = 10 - b: int = 20 - expected: int = 150 + a = 10 + b = 20 + expected = 150 print_log(a=a, b=b, 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 562170a2acf..5fd1ee09df0 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 @@ -86,21 +86,21 @@ def test_warn_the_sheep_wolf_in_middle(self): self.assertEqual(warn_the_sheep(lst), expected) # 2 - lst: list = ['sheep', 'wolf', 'sheep', - 'sheep', 'sheep', 'sheep', - 'sheep'] + lst = ['sheep', 'wolf', 'sheep', + 'sheep', 'sheep', 'sheep', + 'sheep'] - expected: str = 'Oi! Sheep number 5! You are ' \ - 'about to be eaten by a wolf!' + expected = 'Oi! Sheep number 5! You are ' \ + 'about to be eaten by a wolf!' print_log(list=lst, expected=expected) self.assertEqual(warn_the_sheep(lst), expected) # 3 - lst: list = ['sheep', 'wolf', 'sheep'] + lst = ['sheep', 'wolf', 'sheep'] - expected: str = 'Oi! Sheep number 1! You are ' \ - 'about to be eaten by a wolf!' + expected = 'Oi! Sheep number 1! You are ' \ + 'about to be eaten by a wolf!' print_log(list=lst, expected=expected) self.assertEqual(warn_the_sheep(lst), expected)