Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #561 from iKostanOrg/master #562

Merged
merged 106 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
4523ab4
Merge pull request #561 from iKostanOrg/master
ikostan Dec 15, 2024
1781eaa
Create pydocstyle_kyu6.yml
ikostan Dec 15, 2024
17f626e
Update __init__.py
ikostan Dec 15, 2024
f58f8a8
Update __init__.py
ikostan Dec 15, 2024
c30fb64
Array.diff
ikostan Dec 15, 2024
2cfcfcb
Update .yamllint.yaml
ikostan Dec 15, 2024
9af83a5
Array to table
ikostan Dec 17, 2024
0560dde
Binary to text
ikostan Dec 17, 2024
43045c1
Binary to text
ikostan Dec 17, 2024
44d7c29
Update test_list_to_html_table.py
ikostan Dec 17, 2024
ac44d86
Update test_list_to_html_table.py
ikostan Dec 17, 2024
167ebf2
Update test_binary_to_string.py
ikostan Dec 17, 2024
4e717cb
Update test_binary_to_string.py
ikostan Dec 17, 2024
06e3458
Update test_binary_to_string.py
ikostan Dec 17, 2024
a73c8ec
Update test_binary_to_string.py
ikostan Dec 17, 2024
27d8192
Update test_binary_to_string.py
ikostan Dec 17, 2024
ed81bf9
Update test_list_to_html_table.py
ikostan Dec 17, 2024
7b6a0aa
Update test_binary_to_string.py
ikostan Dec 17, 2024
6c213d1
Update test_binary_to_string.py
ikostan Dec 17, 2024
96f2b67
Update test_binary_to_string.py
ikostan Dec 17, 2024
682c9d6
Update test_binary_to_string.py
ikostan Dec 17, 2024
4a5bfbc
Update test_list_to_html_table.py
ikostan Dec 17, 2024
62ae6a5
Update test_binary_to_string.py
ikostan Dec 17, 2024
8d735fd
Update test_binary_to_string.py
ikostan Dec 17, 2024
878727b
# Casino chips
ikostan Dec 17, 2024
05e51ac
Character frequency
ikostan Dec 17, 2024
2fc9911
# Color Choice
ikostan Dec 17, 2024
8f905bf
# Count letters in string
ikostan Dec 17, 2024
8085085
# Decipher this
ikostan Dec 17, 2024
5d92c6e
# DefaultList
ikostan Dec 17, 2024
0e8ff85
# Disease Spread
ikostan Dec 17, 2024
255dd84
# Duplicate Encoder
ikostan Dec 17, 2024
c20735f
# Easy Diagonal
ikostan Dec 17, 2024
43d7540
# Encrypt this
ikostan Dec 17, 2024
ad80b8d
# Find the odd int
ikostan Dec 17, 2024
f482cea
# First character that repeats
ikostan Dec 17, 2024
18b4033
# Format a string of names like 'Bart, Lisa & Maggie'
ikostan Dec 17, 2024
f3f8cf2
# Help the bookseller
ikostan Dec 17, 2024
e762a26
# Character with longest consecutive repetition
ikostan Dec 17, 2024
9ed0edc
# Multiples of 3 or 5
ikostan Dec 17, 2024
e396da8
# No arithmetic progressions
ikostan Dec 17, 2024
b212c8a
# Number Zoo Patrol
ikostan Dec 17, 2024
284430f
Update test_longest_repetition.py
ikostan Dec 17, 2024
7c984c9
Update test_stock_list.py
ikostan Dec 17, 2024
70204c9
Update test_longest_repetition.py
ikostan Dec 17, 2024
11d2069
Update test_alphanumeric.py
ikostan Dec 17, 2024
f49c559
Update test_longest_repetition.py
ikostan Dec 17, 2024
82943ef
Update .codeclimate.yml
ikostan Dec 17, 2024
cadec14
# Numericals of a String
ikostan Dec 17, 2024
84ba365
# Permute a Palindrome
ikostan Dec 17, 2024
62b0ea1
# Pokemon Damage Calculator
ikostan Dec 17, 2024
33c7994
# Potion Class 101
ikostan Dec 17, 2024
1d08d44
# Pyramid Array
ikostan Dec 17, 2024
2ad5d87
# ROTATE THE LETTERS OF EACH ELEMENT
ikostan Dec 17, 2024
a18f2d2
# Row of the odd triangle
ikostan Dec 17, 2024
e4694d7
# Scheduling (Shortest Job First or SJF)
ikostan Dec 17, 2024
ffe8bb9
# Sort the odd
ikostan Dec 17, 2024
061266e
# String subpattern recognition I
ikostan Dec 17, 2024
b778a9a
# String subpattern recognition II
ikostan Dec 17, 2024
cc5ac75
# String subpattern recognition III
ikostan Dec 17, 2024
29d8688
# String transformer
ikostan Dec 17, 2024
77dc370
# Sum of Digits / Digital Root
ikostan Dec 17, 2024
5163e6e
# Sums of Parts
ikostan Dec 17, 2024
edb8fe5
Update test_odd_row.py
ikostan Dec 17, 2024
ec3629f
# Unique In Order
ikostan Dec 18, 2024
b553c77
Update test_sort_array.py
ikostan Dec 18, 2024
0695155
Update unique_in_order.py
ikostan Dec 18, 2024
dbe5410
Update test_unique_in_order.py
ikostan Dec 18, 2024
62d1e18
# Valid Braces
ikostan Dec 18, 2024
168a6b0
# Vasya - Clerk
ikostan Dec 18, 2024
cd22053
# Who likes it
ikostan Dec 18, 2024
00be386
# Your order, please
ikostan Dec 18, 2024
ccf04c4
Update test_order.py
ikostan Dec 18, 2024
54d428c
Update test_order.py
ikostan Dec 18, 2024
0e67a55
Update solution.py
ikostan Dec 18, 2024
f41ac82
Update solution.py
ikostan Dec 18, 2024
e7168bb
Update string_transformer.py
ikostan Dec 18, 2024
ae4fbac
Update group_cities.py
ikostan Dec 18, 2024
535114f
Update thirt.py
ikostan Dec 18, 2024
3f205f0
Update epidemic_test_data.py
ikostan Dec 18, 2024
4f75ac3
Update solution.py
ikostan Dec 18, 2024
274a640
Update sequence.py
ikostan Dec 18, 2024
270a50e
Update sequence.py
ikostan Dec 18, 2024
9dafa55
Update unique_in_order.py
ikostan Dec 18, 2024
c74dcec
Update order.py
ikostan Dec 18, 2024
1d66000
Update sequence.py
ikostan Dec 18, 2024
70891e1
Update default_list.py
ikostan Dec 18, 2024
6dd86f2
Update order.py
ikostan Dec 18, 2024
8e090ea
Update valid_braces.py
ikostan Dec 19, 2024
4c77fc6
Recognition of string subpattern
ikostan Dec 19, 2024
89950bc
Update test_calculate_damage.py
ikostan Dec 19, 2024
360ee7e
Update solution.py
ikostan Dec 19, 2024
8eebd81
Update test_likes_function.py
ikostan Dec 19, 2024
52ba64d
Update test_namelist.py
ikostan Dec 19, 2024
5136bf5
Update test_list_to_html_table.py
ikostan Dec 19, 2024
ddfcd25
Update test_likes_function.py
ikostan Dec 19, 2024
9ce726e
Default list
ikostan Dec 19, 2024
4242c0e
Update test_default_list.py
ikostan Dec 19, 2024
047f607
Update test_default_list.py
ikostan Dec 19, 2024
0ef885f
Update test_order.py
ikostan Dec 19, 2024
85706b4
Edge cases
ikostan Dec 19, 2024
160e6b2
Update test_edge_case_list.py
ikostan Dec 19, 2024
ec4d39b
Update tickets.py
ikostan Dec 19, 2024
34a3d2b
Update test_stock_list.py
ikostan Dec 19, 2024
d5763de
Update test_stock_list.py
ikostan Dec 19, 2024
8f7dce0
Update test_edge_case_list.py
ikostan Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/pydocstyle_kyu6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: pydocstyle for kyu6

on: # yamllint disable-line rule:truthy
push:
branches:
- 'kyu6'

permissions:
contents: read
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.x"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python,
# not the Python version.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install pydocstyle
pip install types-requests
- name: Check to make sure that the module is in your Python path
run: |
echo $PYTHONPATH
- name: Check pydocstyle version
run: |
pydocstyle --version
- name: Doc style checking with pydocstyle
# Pydocstyle testing (Guide)
# https://www.pydocstyle.org/en/stable/usage.html#cli-usage
run: |
pydocstyle --verbose --explain --count kyu_6
4 changes: 2 additions & 2 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ rules:
colons: enable
commas: enable
comments: disable
comments-indentation: disable
document-start: disable
comments-indentation: enable
document-start: enable
empty-lines: enable
empty-values: disable
float-values: disable
Expand Down
1 change: 1 addition & 0 deletions kyu_6/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""6 kyu - Novice package."""
1 change: 1 addition & 0 deletions kyu_6/a_rule_of_divisibility_by_13/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""A Rule of Divisibility by 13."""
1 change: 1 addition & 0 deletions kyu_6/array_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""# Array.diff."""
3 changes: 2 additions & 1 deletion kyu_6/array_diff/solution.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Solution for -> Array.diff
Solution for -> Array.diff.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand Down
51 changes: 23 additions & 28 deletions kyu_6/array_diff/test_array_diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Array.diff
Test for -> Array.diff.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from kyu_6.array_diff.solution import array_diff
from utils.log_func import print_log

Expand All @@ -28,7 +30,7 @@
# pylint: enable-msg=R0801
class ArrayDiffTestCase(unittest.TestCase):
"""
Testing array_diff function
Testing array_diff function.

Your goal in this kata is to implement a difference function,
which subtracts one list from another and returns the result.
Expand All @@ -42,9 +44,16 @@ class ArrayDiffTestCase(unittest.TestCase):
array_diff([1,2,2,2,3],[2]) == [1,3]
"""

def test_array_diff_function(self):
@parameterized.expand([
([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]"),
([1, 2, 2], [], [1, 2, 2], "a was [1,2,2], b was [], expected [1,2,2]"),
([], [1, 2], [], "a was [], b was [1,2], expected []")])
def test_array_diff_function(self, a, b, expected, message):
"""
Testing array_diff function
Testing array_diff function.

:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -59,29 +68,15 @@ def test_array_diff_function(self):
"and returns the result. It should remove all values from "
"list a, which are present in list b.</p>")
# pylint: enable-msg=R0801
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]"),
([1, 2, 2], [], [1, 2, 2], "a was [1,2,2], b was [], expected [1,2,2]"),
([], [1, 2], [], "a was [], b was [1,2], expected []"))

for test_item in test_data:
a: list = test_item[0]
b: list = test_item[1]
expected: list = test_item[2]
message: str = test_item[-1]
with allure.step(f"Enter a test data: {a, b} and verify the "
f"expected output vs actual result: {expected}."):
actual_result: list = array_diff(a, b)
print_log(a=a,
b=b,
exp=expected,
message=message,
actual_result=actual_result)

with allure.step("Enter a test data and verify the "
"expected output vs actual result"):

print_log(a=a,
b=b,
exp=expected,
message=message,
res=actual_result)

self.assertEqual(expected,
actual_result,
message)
self.assertEqual(expected,
actual_result,
message)
1 change: 1 addition & 0 deletions kyu_6/array_to_html_table/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Array to HTML table."""
13 changes: 7 additions & 6 deletions kyu_6/array_to_html_table/test_list_to_html_table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Array to HTML table
Test for -> Array to HTML table.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -25,13 +26,12 @@
url='https://www.codewars.com/kata/5e7e4b7cd889f7001728fd4a',
name='Source/Kata')
class ArrayToTableTestCase(unittest.TestCase):
"""
Testing to_table function
"""
"""Testing to_table function."""

def test_array_to_table_function(self):
"""
Testing to_table with various test data
Testing to_table with various test data.

:return:
"""
# pylint: disable-msg=R0801
Expand Down Expand Up @@ -110,6 +110,7 @@ def test_array_to_table_function(self):
expected = test_item["output"]
actual_result = to_table(data, header, index)

with allure.step("Enter a test data and verify the expected output vs actual result"):
with allure.step("Enter a test data and verify expected"
" output vs actual result"):
print_log(exp=expected, res=actual_result)
self.assertEqual(expected, actual_result)
5 changes: 4 additions & 1 deletion kyu_6/array_to_html_table/to_table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Solution for -> Array to HTML table
Solution for -> Array to HTML table.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -26,6 +27,8 @@

def to_table(data: list, header: bool = False, index: bool = False) -> str:
"""
Array to table.

Takes three arguments: data, headers, index, and returns
a string containing HTML tags representing the table.

Expand Down
1 change: 1 addition & 0 deletions kyu_6/binary_to_text_ascii_conversion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Binary to Text (ASCII) Conversion."""
6 changes: 4 additions & 2 deletions kyu_6/binary_to_text_ascii_conversion/binary_to_string.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Binary to Text (ASCII) Conversion
Solution for -> Binary to Text (ASCII) Conversion.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def binary_to_string(binary: str) -> str:
"""
Binary to string.

Write a function that takes in a binary string
and returns the equivalent decoded text
(the text is ASCII encoded).
Expand All @@ -29,7 +32,6 @@ def binary_to_string(binary: str) -> str:
:param binary:
:return:
"""

if not binary:
return ''

Expand Down
11 changes: 5 additions & 6 deletions kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Binary to Text (ASCII) Conversion
Test for -> Binary to Text (ASCII) Conversion.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand Down Expand Up @@ -29,14 +30,12 @@
url='https://www.codewars.com/kata/5583d268479559400d000064',
name='Source/Kata')
class SequenceTestCase(unittest.TestCase):
"""
Testing binary_to_string function
"""
"""Testing binary_to_string function."""

def test_binary_to_string(self):
"""
Testing binary_to_string function
with various test data
Testing binary_to_string function with various test data.

:return:
"""
# pylint: disable-msg=R0801
Expand Down
1 change: 1 addition & 0 deletions kyu_6/casino_chips/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Casino chips."""
6 changes: 4 additions & 2 deletions kyu_6/casino_chips/solve.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for Casino chips
Solution for Casino chips.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def solve(arr: list) -> int:
"""
Solve function.

You are given three piles of casino chips: white, green and black
chips:

Expand All @@ -26,7 +29,6 @@ def solve(arr: list) -> int:
:return:
"""
arr = sorted(arr)

if arr[0] + arr[1] <= arr[2]:
return arr[0] + arr[1]

Expand Down
62 changes: 28 additions & 34 deletions kyu_6/casino_chips/test_solve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for Casino chips
Test for Casino chips.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from kyu_6.casino_chips.solve import solve
from utils.log_func import print_log

Expand All @@ -28,12 +30,26 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class SolveTestCase(unittest.TestCase):
"""
Testing solve function
"""
def test_solve(self):
"""Testing solve function."""

@parameterized.expand([
([8, 8, 8], 12),
([1, 1, 1], 1),
([8, 1, 4], 5),
([7, 4, 10], 10),
([12, 12, 12], 18),
([6, 6, 6], 9),
([1, 23, 2], 3),
([9, 8, 6], 11),
([10, 9, 6], 12),
([4, 4, 3], 5),
([1, 2, 1], 2),
([4, 1, 1], 2),
([8, 2, 8], 9)])
def test_solve(self, arr, expected):
"""
Testing 'solve' function with various test data
Testing 'solve' function with various test data.

:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -49,31 +65,9 @@ def test_solve(self):
"maximum number of days you can pick the chips. Each "
"day you need to take exactly two chips.</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
([8, 8, 8], 12),
([1, 1, 1], 1),
([8, 1, 4], 5),
([7, 4, 10], 10),
([12, 12, 12], 18),
([6, 6, 6], 9),
([1, 23, 2], 3),
([9, 8, 6], 11),
([10, 9, 6], 12),
([4, 4, 3], 5),
([1, 2, 1], 2),
([4, 1, 1], 2),
([8, 2, 8], 9))

for arr, expected in test_data:
actual_result = solve(arr)

with allure.step(f"Enter an array ({arr}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):

print_log(arr=arr,
expected=expected,
result=actual_result)

self.assertEqual(expected,
actual_result)
actual_result = solve(arr)
with allure.step(f"Enter an array ({arr}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):
print_log(arr=arr, expected=expected, result=actual_result)
self.assertEqual(expected, actual_result)
1 change: 1 addition & 0 deletions kyu_6/character_frequency/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Character frequency."""
Loading
Loading