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 #572 from iKostanOrg/master #573

Merged
merged 58 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d28a7f6
Merge pull request #572 from iKostanOrg/master
ikostan Dec 22, 2024
7fa7c05
Create pydocstyle_kyu8.yml
ikostan Dec 22, 2024
b58a30c
Update __init__.py
ikostan Dec 22, 2024
4e7cae1
ALTerNAtiNG CaSe
ikostan Dec 22, 2024
8f11948
Update alternating_case.py
ikostan Dec 22, 2024
99ac469
# Century From Year
ikostan Dec 22, 2024
a7119bf
# Check the exam
ikostan Dec 22, 2024
9a68f04
# Convert a string to an array
ikostan Dec 24, 2024
e2654a6
Count the Monkeys!.
ikostan Dec 24, 2024
3ffa4e1
Counting sheep
ikostan Dec 24, 2024
2905ff4
Enumerable Magic #25 - Take the First N Elements.
ikostan Dec 24, 2024
625967a
# Find the first non-consecutive number
ikostan Dec 24, 2024
7e6d0be
Formatting decimal places #0
ikostan Dec 24, 2024
477fc50
Grasshopper
ikostan Dec 24, 2024
a0dd265
# Grasshopper - Messi goals function
ikostan Dec 24, 2024
19e631f
Personalized greeting
ikostan Dec 24, 2024
097e59c
Grasshopper - Summation
ikostan Dec 24, 2024
033aef3
# Greek Sort
ikostan Dec 24, 2024
718d2c7
Update __init__.py
ikostan Dec 24, 2024
07fa235
closest_elevator
ikostan Dec 24, 2024
aa02db4
Update closest_elevator.py
ikostan Dec 24, 2024
2e5bc5a
Update requirements.txt
ikostan Dec 24, 2024
07c1851
# Holiday VI - Shark Pontoon
ikostan Dec 24, 2024
d20c550
kyu_8 docs
ikostan Dec 24, 2024
6d62247
# Is it a palindrome
ikostan Dec 24, 2024
3e56bf3
# MakeUpperCase
ikostan Dec 24, 2024
58114cd
multiply
ikostan Dec 24, 2024
aec5c89
My head is at the wrong end.
ikostan Dec 24, 2024
175679b
Remove First and Last Character
ikostan Dec 24, 2024
ec31847
Remove String Spaces.
ikostan Dec 24, 2024
f72d3f3
Update kyu_8.rst
ikostan Dec 24, 2024
8ea0a8c
Reversed Strings.
ikostan Dec 24, 2024
ba6be03
L1: Set Alarm
ikostan Dec 24, 2024
07a0849
Surface Area and Volume of a Box.
ikostan Dec 24, 2024
738530b
Swap Values.
ikostan Dec 24, 2024
058650e
Grasshopper - Terminal game move function.
ikostan Dec 24, 2024
f7652d8
The Feast of Many Beasts.
ikostan Dec 24, 2024
ea57838
Third Angle of a Triangle.
ikostan Dec 24, 2024
36b83c2
Well of Ideas - Easy Version
ikostan Dec 24, 2024
6b9f1b3
Will there be enough space?.
ikostan Dec 24, 2024
309a6ef
# Will you make it
ikostan Dec 24, 2024
746f6d1
A wolf in sheep's clothing.
ikostan Dec 24, 2024
5083d45
# Keep Hydrated
ikostan Dec 24, 2024
fd0ddb5
Update evaluator.py
ikostan Dec 24, 2024
d08cdaa
Update make_upper_case.py
ikostan Dec 24, 2024
f32c8cd
Update enough.py
ikostan Dec 24, 2024
aced1db
keep_up_the_hoop
ikostan Dec 24, 2024
78a128e
logical_calculator
ikostan Dec 24, 2024
50e4ef2
is_your_period_late
ikostan Dec 24, 2024
8c11693
set_alarm
ikostan Dec 24, 2024
341a31f
Update test_set_alarm.py
ikostan Dec 24, 2024
6532bb5
Update logical_calculator.py
ikostan Dec 24, 2024
d908bcb
Update check_exam.py
ikostan Dec 24, 2024
ffff071
Update well_of_ideas_easy_version.py
ikostan Dec 24, 2024
a6c59da
Update evaluator.py
ikostan Dec 24, 2024
82c1c83
Update evaluator.py
ikostan Dec 24, 2024
3f63da4
Update test_third_angle_of_triangle.py
ikostan Dec 24, 2024
f1d31ca
Update test_third_angle_of_triangle.py
ikostan Dec 24, 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_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
Loading