Skip to content

Commit

Permalink
Merge pull request #573 from iKostanOrg/kyu8
Browse files Browse the repository at this point in the history
Merge pull request #572 from iKostanOrg/master
  • Loading branch information
ikostan authored Dec 24, 2024
2 parents 8e5724a + f1d31ca commit 8fdde8e
Show file tree
Hide file tree
Showing 120 changed files with 1,083 additions and 833 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pydocstyle_kyu8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: pydocstyle for kyu8

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

permissions:
contents: read
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.x"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python,
# not the Python version.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install pydocstyle
pip install types-requests
- name: Check to make sure that the module is in your Python path
run: |
echo $PYTHONPATH
- name: Check pydocstyle version
run: |
pydocstyle --version
- name: Doc style checking with pydocstyle
# Pydocstyle testing (Guide)
# https://www.pydocstyle.org/en/stable/usage.html#cli-usage
run: |
pydocstyle --verbose --explain --count kyu_8
32 changes: 32 additions & 0 deletions docs/kyu_8/kyu_8.closest_elevator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
kyu\_8.closest\_elevator package
================================

Submodules
----------

kyu\_8.closest\_elevator.closest\_elevator module
-------------------------------------------------

.. automodule:: kyu_8.closest_elevator.closest_elevator
:members:
:undoc-members:
:show-inheritance:
:private-members:

kyu\_8.closest\_elevator.test\_closest\_elevator module
-------------------------------------------------------

.. automodule:: kyu_8.closest_elevator.test_closest_elevator
:members:
:undoc-members:
:show-inheritance:
:private-members:

Module contents
---------------

.. automodule:: kyu_8.closest_elevator
:members:
:undoc-members:
:show-inheritance:
:private-members:
10 changes: 5 additions & 5 deletions docs/kyu_8/kyu_8.greek_sort.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ kyu\_8.greek\_sort package
Submodules
----------

kyu\_8.greek\_sort.greek\_comparator module
-------------------------------------------
kyu\_8.greek\_sort.evaluator module
-----------------------------------

.. automodule:: kyu_8.greek_sort.greek_comparator
.. automodule:: kyu_8.greek_sort.evaluator
:members:
:undoc-members:
:show-inheritance:
:private-members:

kyu\_8.greek\_sort.evaluator module
kyu\_8.greek\_sort.greek\_comparator module
-------------------------------------------

.. automodule:: kyu_8.greek_sort.evaluator
.. automodule:: kyu_8.greek_sort.greek_comparator
:members:
:undoc-members:
:show-inheritance:
Expand Down
1 change: 1 addition & 0 deletions docs/kyu_8/kyu_8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Subpackages
kyu_8.alternating_case
kyu_8.century_from_year
kyu_8.check_the_exam
kyu_8.closest_elevator
kyu_8.convert_string_to_an_array
kyu_8.count_the_monkeys
kyu_8.counting_sheep
Expand Down
79 changes: 40 additions & 39 deletions kyu_8/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions kyu_8/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""8 kyu - Beginner package."""
1 change: 1 addition & 0 deletions kyu_8/alternating_case/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""altERnaTIng cAsE <=> ALTerNAtiNG CaSe."""
13 changes: 8 additions & 5 deletions kyu_8/alternating_case/alternating_case.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""
altERnaTIng cAsE <=> ALTerNAtiNG CaSe
altERnaTIng cAsE <=> ALTerNAtiNG CaSe.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def to_alternating_case(string: str) -> str:
"""
each lowercase letter becomes uppercase and
each uppercase letter becomes lowercase
:param string:
:return:
Alternating case.
Each lowercase letter becomes uppercase and
each uppercase letter becomes lowercase.
:param string: str
:return: str
"""
return ''.join((char.upper() if char.islower() else char.lower()) for char in string)
51 changes: 25 additions & 26 deletions kyu_8/alternating_case/test_alternating_case.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Testing for altERnaTIng cAsE <=> ALTerNAtiNG CaSe
Testing for altERnaTIng cAsE <=> ALTerNAtiNG CaSe.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.alternating_case.alternating_case \
import to_alternating_case
Expand All @@ -26,40 +28,37 @@
name='Source/Kata')
# pylint: enable=R0801
class AlternatingCaseTestCase(unittest.TestCase):
"""
Testing to_alternating_case function
"""
"""Testing to_alternating_case function."""

def test_alternating_case(self):
@parameterized.expand([
("hello world", "HELLO WORLD"),
("HELLO WORLD", "hello world"),
("HeLLo WoRLD", "hEllO wOrld"),
("hello WORLD", "HELLO world"),
("12345", "12345"),
("1a2b3c4d5e", "1A2B3C4D5E"),
("String.prototype.toAlternatingCase",
"sTRING.PROTOTYPE.TOaLTERNATINGcASE"),
("Hello World", "hELLO wORLD"),
("altERnaTIng cAsE", "ALTerNAtiNG CaSe")])
def test_alternating_case(self, string, expected):
"""
Testing to_alternating_case function
Testing to_alternating_case function with various test data.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Testing to_alternating_case function")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
with allure.step("Enter test string and verify the output"):
test_data: tuple = (
("hello world", "HELLO WORLD"),
("HELLO WORLD", "hello world"),
("HeLLo WoRLD", "hEllO wOrld"),
("hello WORLD", "HELLO world"),
("12345", "12345"),
("1a2b3c4d5e", "1A2B3C4D5E"),
("String.prototype.toAlternatingCase",
"sTRING.PROTOTYPE.TOaLTERNATINGcASE"),
("Hello World", "hELLO wORLD"),
("altERnaTIng cAsE", "ALTerNAtiNG CaSe"))

for d in test_data:
string = d[0]
expected = d[1]
print_log(string=string, expected=expected)
self.assertEqual(to_alternating_case(string), expected)
with allure.step(f"Enter test string: {string} "
f"and verify the expected output: {expected}."):
print_log(string=string, expected=expected)
self.assertEqual(to_alternating_case(string), expected)
1 change: 1 addition & 0 deletions kyu_8/century_from_year/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Century From Year."""
6 changes: 4 additions & 2 deletions kyu_8/century_from_year/century.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""
Solution for -> Century From Year
Solution for -> Century From Year.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def century(year: int) -> int:
"""
Given a year, return the century it is in
Given a year, return the century it is in.
:param year: int
:return: int
"""
Expand Down
58 changes: 30 additions & 28 deletions kyu_8/century_from_year/test_century.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Century From Year
Test for -> Century From Year.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -9,6 +10,7 @@

import unittest
import allure
from parameterized import parameterized
from kyu_8.century_from_year.century import century
from utils.log_func import print_log

Expand All @@ -32,45 +34,45 @@
# pylint: enable-msg=R0801
class CenturyTestCase(unittest.TestCase):
"""
Testing century function.
The first century spans from the year 1 up to and
including the year 100, The second - from the year
101 up to and including the year 200, etc.
"""

def test_century(self):
@parameterized.expand([
(1705, 18, 'Testing for year 1705'),
(1900, 19, 'Testing for year 1900'),
(1601, 17, 'Testing for year 1601'),
(2000, 20, 'Testing for year 2000'),
(356, 4, 'Testing for year 356'),
(89, 1, 'Testing for year 89')])
def test_century(self, year, expected, message):
"""
Testing century function
Testing century function with various test data.
:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title("Testing century function")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p>Given a year, the function should return the century it is in."
"<p>Given a year, the function should return "
"the century it is in."
"</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
(1705, 18, 'Testing for year 1705'),
(1900, 19, 'Testing for year 1900'),
(1601, 17, 'Testing for year 1601'),
(2000, 20, 'Testing for year 2000'),
(356, 4, 'Testing for year 356'),
(89, 1, 'Testing for year 89'))

for year, expected, message in test_data:
result: int = century(year)

with allure.step(f"Enter test year ({year}) and verify "
f"the output ({result}) "
f"vs expected ({expected})"):

print_log(year=year,
result=result,
expected=expected,
message=message)

self.assertEqual(expected,
result)
result: int = century(year)
with allure.step(f"Enter test year ({year}) and verify "
f"the output ({result}) "
f"vs expected ({expected})"):
print_log(year=year,
result=result,
expected=expected,
message=message)
self.assertEqual(expected, result)
1 change: 1 addition & 0 deletions kyu_8/check_the_exam/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Check the exam."""
8 changes: 6 additions & 2 deletions kyu_8/check_the_exam/check_exam.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Check the exam
Solution for -> Check the exam.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def check_exam(arr1: list, arr2: list) -> int:
"""
Check exam.
The first input array contains the correct answers
to an exam, like ["a", "a", "b", "d"]. The second
one is "answers" array and contains student's answers.
Expand All @@ -32,7 +35,8 @@ def check_exam(arr1: list, arr2: list) -> int:

def char_processor(char: tuple, results: list) -> None:
"""
Processing chars based on specified rule
Process chars based on specified rule.
:param char: str
:param results: list
:return: None
Expand Down
Loading

0 comments on commit 8fdde8e

Please sign in to comment.