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): '
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): '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": "True | False | False | True | " "True |
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 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('