From 94ac9d5abee7be6fb6cfeb330a1b802f28aac048 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Sun, 22 Dec 2024 13:46:31 -0800
Subject: [PATCH 01/81] Update README.md
---
README.md | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index cdec1fb788d..1e7faaefbfa 100644
--- a/README.md
+++ b/README.md
@@ -354,13 +354,11 @@ the environment for every build, see comment from Grimmy below).
Given a year, the function should return the century it is in."
+ " Given a year, the function should return "
+ "the century it is in."
" Create a method take that accepts a list/array and a"
" number n, and returns a list/array array of the first "
@@ -49,31 +56,14 @@ def test_take(self):
"https://docs.python.org/3/library/stdtypes"
".html#sequence-types-list-tuple-range A custom comparison function of two arguments (iterable"
" elements) which should return a negative, zero or positive"
@@ -48,26 +53,17 @@ def test_greek_comparator(self):
" smaller than, equal to, or larger than the second argument"
" isPalindrome that checks if a given string "
+ "(case insensitive) is a palindrome. Make sure 'make_upper_case' function convert "
+ "strings to UpperCase.ERROR: The term 'make' is not recognized as the name of a cmdlet
-'make' is not recognized as an internal or external command.
-
The error "'make' is not recognized as an internal or external command, operable program or
batch file" occurs when we run the make command on Windows without having make installed.
To solve the error, install make using Chocolatey.
-```
+```bash
make clean
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
@@ -378,18 +376,18 @@ To install Chocolatey:
1. Open PowerShell as an administrator.
2. Run the following command:
- ```
+ ```bash
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
3. Wait for the command to complete.
4. Type choco to make sure Chocolatey is installed:
- ```
+ ```bash
PS C:\WINDOWS\system32> choco
Chocolatey v2.4.1
Please run 'choco -?' or 'choco Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# 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)
From 8f119481e12168ff46a59eb59580aab471ab24d1 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Sun, 22 Dec 2024 14:16:04 -0800
Subject: [PATCH 05/81] Update alternating_case.py
---
kyu_8/alternating_case/alternating_case.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kyu_8/alternating_case/alternating_case.py b/kyu_8/alternating_case/alternating_case.py
index 44c51a05212..f298b2e7c23 100644
--- a/kyu_8/alternating_case/alternating_case.py
+++ b/kyu_8/alternating_case/alternating_case.py
@@ -10,7 +10,7 @@ def to_alternating_case(string: str) -> str:
"""
Alternating case.
- each lowercase letter becomes uppercase and
+ Each lowercase letter becomes uppercase and
each uppercase letter becomes lowercase.
:param string: str
:return: str
From 99ac469e08b75e2e1e2b6ee116be6f1f6e82000a Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Sun, 22 Dec 2024 14:25:04 -0800
Subject: [PATCH 06/81] # Century From Year
---
kyu_8/century_from_year/__init__.py | 1 +
kyu_8/century_from_year/century.py | 6 ++-
kyu_8/century_from_year/test_century.py | 58 +++++++++++++------------
3 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/kyu_8/century_from_year/__init__.py b/kyu_8/century_from_year/__init__.py
index e69de29bb2d..228c0682982 100644
--- a/kyu_8/century_from_year/__init__.py
+++ b/kyu_8/century_from_year/__init__.py
@@ -0,0 +1 @@
+"""Century From Year."""
diff --git a/kyu_8/century_from_year/century.py b/kyu_8/century_from_year/century.py
index b3687eb368f..b6406ec4aa0 100644
--- a/kyu_8/century_from_year/century.py
+++ b/kyu_8/century_from_year/century.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Century From Year
+Solution for -> Century From Year.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,7 +8,8 @@
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
"""
diff --git a/kyu_8/century_from_year/test_century.py b/kyu_8/century_from_year/test_century.py
index 1c86b9c549c..37cf962a18b 100644
--- a/kyu_8/century_from_year/test_century.py
+++ b/kyu_8/century_from_year/test_century.py
@@ -1,5 +1,6 @@
"""
-Test for -> Century From Year
+Test for -> Century From Year.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -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
@@ -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(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
- "Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
with allure.step("Enter arr1 and arr2 and verify the output"):
- data: tuple = (
- (["a", "a", "b", "b"], ["a", "c", "b", "d"], 6),
- (["a", "a", "c", "b"], ["a", "a", "b", ""], 7),
- (["a", "a", "b", "c"], ["a", "a", "b", "c"], 16),
- (["b", "c", "b", "a"], ["", "a", "a", "c"], 0))
-
- for arr1, arr2, expected in data:
- print_log(arr1=arr1,
- arr2=arr2,
- expected=expected)
-
- self.assertEqual(expected,
- check_exam(arr1, arr2))
+ print_log(arr1=arr1, arr2=arr2, expected=expected)
+ self.assertEqual(expected, check_exam(arr1, arr2))
From 9a68f048faf41cf50ed5f7b014eff736a8b04e75 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 02:15:55 -0800
Subject: [PATCH 08/81] # Convert a string to an array
---
kyu_8/convert_string_to_an_array/__init__.py | 1 +
.../string_to_array.py | 7 ++--
.../test_string_to_array.py | 33 +++++++++----------
3 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/kyu_8/convert_string_to_an_array/__init__.py b/kyu_8/convert_string_to_an_array/__init__.py
index e69de29bb2d..a236a70d07e 100644
--- a/kyu_8/convert_string_to_an_array/__init__.py
+++ b/kyu_8/convert_string_to_an_array/__init__.py
@@ -0,0 +1 @@
+"""Convert a string to an array."""
diff --git a/kyu_8/convert_string_to_an_array/string_to_array.py b/kyu_8/convert_string_to_an_array/string_to_array.py
index 724f48905f5..14fa4a648a0 100644
--- a/kyu_8/convert_string_to_an_array/string_to_array.py
+++ b/kyu_8/convert_string_to_an_array/string_to_array.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Convert a string to an array
+Solution for -> Convert a string to an array.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,8 +8,8 @@
def string_to_array(s: str) -> list:
"""
- A function to split a string and
- convert it into an array of words
+ Split a string and convert it into an array of words.
+
:param s: str
:return: list
"""
diff --git a/kyu_8/convert_string_to_an_array/test_string_to_array.py b/kyu_8/convert_string_to_an_array/test_string_to_array.py
index d389160b0cd..72f48dfe51e 100644
--- a/kyu_8/convert_string_to_an_array/test_string_to_array.py
+++ b/kyu_8/convert_string_to_an_array/test_string_to_array.py
@@ -1,5 +1,6 @@
"""
-Test for -> Convert a string to an array
+Test for -> Convert a string to an array.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.convert_string_to_an_array.string_to_array \
import string_to_array
@@ -28,11 +30,16 @@
name='Source/Kata')
# pylint: enable=R0801
class StringToArrayTestCase(unittest.TestCase):
- """
- Testing string_to_array function.
- """
+ """Testing string_to_array function."""
- def test_string_to_array(self):
+ @parameterized.expand([
+ ("Robin Singh", ["Robin", "Singh"]),
+ ("CodeWars", ["CodeWars"]),
+ ("I love arrays they are my favorite",
+ ["I", "love", "arrays", "they", "are", "my", "favorite"]),
+ ("1 2 3", ["1", "2", "3"]),
+ ("", [""])])
+ def test_string_to_array(self, s, expected):
"""
Testing string_to_array function.
@@ -50,15 +57,7 @@ def test_string_to_array(self):
'Test Description:
'
"")
# pylint: enable=R0801
- with allure.step("Enter a test string and verify the output"):
- test_data: tuple = (
- ("Robin Singh", ["Robin", "Singh"]),
- ("CodeWars", ["CodeWars"]),
- ("I love arrays they are my favorite",
- ["I", "love", "arrays", "they", "are", "my", "favorite"]),
- ("1 2 3", ["1", "2", "3"]),
- ("", [""]))
-
- for s, expected in test_data:
- print_log(s=s, expected=expected)
- self.assertEqual(expected, string_to_array(s))
+ with allure.step(f"Enter a test string: {s} "
+ f"and verify the output: {expected}."):
+ print_log(s=s, expected=expected)
+ self.assertEqual(expected, string_to_array(s))
From e2654a6522fd7a2dc556f3e773bd26bbe99508fe Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 02:22:14 -0800
Subject: [PATCH 09/81] Count the Monkeys!.
---
kyu_8/count_the_monkeys/__init__.py | 1 +
kyu_8/count_the_monkeys/monkey_count.py | 5 ++-
kyu_8/count_the_monkeys/test_monkey_count.py | 37 ++++++++++----------
3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/kyu_8/count_the_monkeys/__init__.py b/kyu_8/count_the_monkeys/__init__.py
index e69de29bb2d..3eca16bf08d 100644
--- a/kyu_8/count_the_monkeys/__init__.py
+++ b/kyu_8/count_the_monkeys/__init__.py
@@ -0,0 +1 @@
+"""Count the Monkeys."""
diff --git a/kyu_8/count_the_monkeys/monkey_count.py b/kyu_8/count_the_monkeys/monkey_count.py
index c089aa86894..bf4467b021a 100644
--- a/kyu_8/count_the_monkeys/monkey_count.py
+++ b/kyu_8/count_the_monkeys/monkey_count.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Count the Monkeys!
+Solution for -> Count the Monkeys!.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,6 +8,8 @@
def monkey_count(n: int) -> list:
"""
+ Count monkeys.
+
You take your son to the forest to see the monkeys.
You know that there are a certain number there (n),
but your son is too young to just appreciate the full
diff --git a/kyu_8/count_the_monkeys/test_monkey_count.py b/kyu_8/count_the_monkeys/test_monkey_count.py
index 095047df308..24e7e002a84 100644
--- a/kyu_8/count_the_monkeys/test_monkey_count.py
+++ b/kyu_8/count_the_monkeys/test_monkey_count.py
@@ -1,5 +1,6 @@
"""
-Test for -> Count the Monkeys!
+Test for -> Count the Monkeys!.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -9,6 +10,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.count_the_monkeys.monkey_count \
import monkey_count
@@ -33,13 +35,19 @@
name='Source/Kata')
# pylint: enable=R0801
class MonkeyCountTestCase(unittest.TestCase):
- """
- Testing monkey_count function
- """
+ """Testing monkey_count function."""
- def test_monkey_count(self):
+ @parameterized.expand([
+ (1, [1]),
+ (5, [1, 2, 3, 4, 5]),
+ (3, [1, 2, 3]),
+ (9, [1, 2, 3, 4, 5, 6, 7, 8, 9]),
+ (10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
+ (20, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20])])
+ def test_monkey_count(self, n, expected):
"""
- Testing monkey_count function
+ Testing monkey_count function.
You take your son to the forest to see the monkeys.
You know that there are a certain number there (n),
@@ -62,16 +70,7 @@ def test_monkey_count(self):
'Test Description:
'
"")
# pylint: enable=R0801
- with allure.step("Enter a number (int) and verify the output"):
- test_data: tuple = (
- (1, [1]),
- (5, [1, 2, 3, 4, 5]),
- (3, [1, 2, 3]),
- (9, [1, 2, 3, 4, 5, 6, 7, 8, 9]),
- (10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
- (20, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 20]))
-
- for n, expected in test_data:
- print_log(n=n, expected=expected)
- self.assertEqual(expected, monkey_count(n))
+ with allure.step(f"Enter a number (int): {n} "
+ f"and verify the expected output: {expected}."):
+ print_log(n=n, expected=expected)
+ self.assertEqual(expected, monkey_count(n))
From 3ffa4e19888c40dea4b5284c66d4bee31aa5d08e Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 02:29:19 -0800
Subject: [PATCH 10/81] Counting sheep
---
kyu_8/counting_sheep/__init__.py | 1 +
kyu_8/counting_sheep/counting_sheep.py | 13 +++--
kyu_8/counting_sheep/test_counting_sheep.py | 56 ++++++++++++---------
3 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/kyu_8/counting_sheep/__init__.py b/kyu_8/counting_sheep/__init__.py
index e69de29bb2d..b676058b62c 100644
--- a/kyu_8/counting_sheep/__init__.py
+++ b/kyu_8/counting_sheep/__init__.py
@@ -0,0 +1 @@
+"""Counting sheep."""
diff --git a/kyu_8/counting_sheep/counting_sheep.py b/kyu_8/counting_sheep/counting_sheep.py
index be4c8583b89..8ade6f78b92 100644
--- a/kyu_8/counting_sheep/counting_sheep.py
+++ b/kyu_8/counting_sheep/counting_sheep.py
@@ -1,12 +1,15 @@
"""
Solution for -> Counting sheep...
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
-def count_sheeps(array_of_sheeps: list) -> int:
+def count_sheep(array_of_sheep: list) -> int:
"""
+ Count sheep.
+
Consider an array of sheep where some sheep
may be missing from their place. We need a
function that counts the number of sheep
@@ -14,8 +17,8 @@ def count_sheeps(array_of_sheeps: list) -> int:
Hint: Don't forget to check for bad values
like null/undefined
- :param array_of_sheeps:
- :return:
+ :param array_of_sheep: list
+ :return: int
"""
- return 0 if array_of_sheeps is None \
- else array_of_sheeps.count(True)
+ return 0 if array_of_sheep is None \
+ else array_of_sheep.count(True)
diff --git a/kyu_8/counting_sheep/test_counting_sheep.py b/kyu_8/counting_sheep/test_counting_sheep.py
index 5b48b889a49..0f1c9eb47bd 100644
--- a/kyu_8/counting_sheep/test_counting_sheep.py
+++ b/kyu_8/counting_sheep/test_counting_sheep.py
@@ -1,5 +1,6 @@
"""
Test for -> Counting sheep...
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -9,7 +10,7 @@
import unittest
import allure
from utils.log_func import print_log
-from kyu_8.counting_sheep.counting_sheep import count_sheeps
+from kyu_8.counting_sheep.counting_sheep import count_sheep
# pylint: disable=R0801
@@ -26,13 +27,12 @@
name='Source/Kata')
# pylint: enable=R0801
class CountingSheepTestCase(unittest.TestCase):
- """
- Testing 'count_sheeps' function
- """
+ """Testing 'count_sheep' function."""
def test_counting_sheep(self):
"""
- Testing 'count_sheeps' function
+ Testing 'count_sheep' function.
+
Consider an array of sheep where some sheep
may be missing from their place.
We need a function that counts the
@@ -42,12 +42,13 @@ def test_counting_sheep(self):
"""
# pylint: disable=R0801
allure.dynamic.title(
- "Testing 'count_sheeps' function: positive flow")
+ "Testing 'count_sheep' function: positive flow")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
@@ -60,13 +61,14 @@ def test_counting_sheep(self):
expected: int = 17
print_log(list=lst, expected=expected)
self.assertEqual(expected,
- count_sheeps(lst),
+ count_sheep(lst),
f"There are 17 sheep in total, "
- f"not {count_sheeps(lst)}")
+ f"not {count_sheep(lst)}")
def test_counting_sheep_bad_input(self):
"""
- Testing 'count_sheeps' function
+ Testing 'count_sheep' function, invalid values.
+
Hint: Don't forget to check for
bad values like null/undefined
:return:
@@ -86,25 +88,27 @@ def test_counting_sheep_bad_input(self):
expected: int = 0
print_log(list=lst, expected=expected)
self.assertEqual(expected,
- count_sheeps(lst),
+ count_sheep(lst),
f"There are 0 sheep in total, "
- f"not {count_sheeps(lst)}")
+ f"not {count_sheep(lst)}")
def test_counting_sheep_empty_list(self):
"""
- Testing 'count_sheeps' function
+ Testing 'count_sheep' function, empty list.
+
Hint: Don't forget to check for
bad values like empty list
:return:
"""
# pylint: disable=R0801
allure.dynamic.title(
- "Testing 'count_sheeps' function: empty list")
+ "Testing 'count_sheep' function: empty list")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
@@ -112,25 +116,27 @@ def test_counting_sheep_empty_list(self):
expected: int = 0
print_log(list=lst, expected=expected)
self.assertEqual(expected,
- count_sheeps(lst),
+ count_sheep(lst),
f"There are 0 sheep in total, "
- f"not {count_sheeps(lst)}")
+ f"not {count_sheep(lst)}")
def test_counting_sheep_mixed_list(self):
"""
- Testing 'count_sheeps' function
+ Testing 'count_sheep' function, null value.
+
Hint: Don't forget to check for
bad values like mixed list
:return:
"""
# pylint: disable=R0801
allure.dynamic.title(
- "Testing 'count_sheeps' function: mixed list")
+ "Testing 'count_sheep' function: mixed list")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
@@ -138,6 +144,6 @@ def test_counting_sheep_mixed_list(self):
expected: int = 1
print_log(list=lst, expected=expected)
self.assertEqual(expected,
- count_sheeps(lst),
+ count_sheep(lst),
f"There are 0 sheep in total, "
- f"not {count_sheeps(lst)}")
+ f"not {count_sheep(lst)}")
From 2905ff43b8a23d848c11044efc3b400ad38abee6 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 02:34:18 -0800
Subject: [PATCH 11/81] Enumerable Magic #25 - Take the First N Elements.
---
kyu_8/enumerable_magic_25/__init__.py | 1 +
kyu_8/enumerable_magic_25/take.py | 7 +++-
kyu_8/enumerable_magic_25/test_take.py | 52 +++++++++++---------------
3 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/kyu_8/enumerable_magic_25/__init__.py b/kyu_8/enumerable_magic_25/__init__.py
index e69de29bb2d..410c8d0558c 100644
--- a/kyu_8/enumerable_magic_25/__init__.py
+++ b/kyu_8/enumerable_magic_25/__init__.py
@@ -0,0 +1 @@
+"""Enumerable Magic #25 - Take the First N Elements."""
diff --git a/kyu_8/enumerable_magic_25/take.py b/kyu_8/enumerable_magic_25/take.py
index 107e0bb3450..0512f533432 100644
--- a/kyu_8/enumerable_magic_25/take.py
+++ b/kyu_8/enumerable_magic_25/take.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Enumerable Magic #25 - Take the First N Elements
+Solution for -> Enumerable Magic #25 - Take the First N Elements.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,8 +8,10 @@
def take(arr: list, n: int) -> list:
"""
+ 'take' function.
+
Accepts a list/array and a number n,
- and returns a list/array array of the
+ and returns a list/array of the
first n elements from the list/array.
:param arr: list
diff --git a/kyu_8/enumerable_magic_25/test_take.py b/kyu_8/enumerable_magic_25/test_take.py
index ab1cb2d98ba..97d7be1a043 100644
--- a/kyu_8/enumerable_magic_25/test_take.py
+++ b/kyu_8/enumerable_magic_25/test_take.py
@@ -1,5 +1,6 @@
"""
-Test for -> Enumerable Magic #25 - Take the First N Elements
+Test for -> Enumerable Magic #25 - Take the First N Elements.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.enumerable_magic_25.take import take
@@ -25,13 +27,17 @@
name='Source/Kata')
# pylint: enable=R0801
class TakeTestCase(unittest.TestCase):
- """
- Testing take function
- """
+ """Testing 'take' function."""
- def test_take(self):
+ @parameterized.expand([
+ ([0, 1, 2, 3, 5, 8, 13], 3, [0, 1, 2]),
+ ([51], 35, [51]),
+ ([], 3, []),
+ ([0, 1, 2, 3, 5, 8, 13], 0, [])])
+ def test_take(self, arr, n, expected):
"""
- Testing the function with various test data
+ Testing the function with various test data.
+
:return:
"""
# pylint: disable=R0801
@@ -39,8 +45,9 @@ def test_take(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
- with allure.step("Pass a list with no non consecutive numbers"):
+ with allure.step("Pass a list with non-consecutive numbers"):
lst: list = [1, 2, 3, 4, 5, 6, 7, 8]
expected: None = None
@@ -62,7 +64,8 @@ def test_first_non_consecutive_none(self):
def test_first_non_consecutive_large_list(self):
"""
- Large lists
+ Testing large lists.
+
:return:
"""
# pylint: disable=R0801
@@ -70,8 +73,9 @@ def test_first_non_consecutive_large_list(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
@@ -114,6 +118,8 @@ def test_first_non_consecutive_large_list(self):
def test_first_non_consecutive_positive(self):
"""
+ Test non-consecutive positive numbers.
+
If we have an array [1,2,3,4,6,7,8] then 1 then 2
then 3 then 4 are all consecutive but 6 is not,
so that's the first non-consecutive number.
@@ -124,8 +130,9 @@ def test_first_non_consecutive_positive(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
@@ -170,16 +177,19 @@ def test_first_non_consecutive_positive(self):
def test_first_non_consecutive_negative(self):
"""
- non-consecutive is a negative number.
+ Test non-consecutive is a negative number.
+
:return:
"""
# pylint: disable=R0801
- allure.dynamic.title("Negative non consecutive number should be returned")
+ allure.dynamic.title(
+ "Negative non consecutive number should be returned")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
From 7e6d0be998929659dbd5cdb2ac5deae6381babd3 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 02:57:05 -0800
Subject: [PATCH 13/81] Formatting decimal places #0
---
kyu_8/formatting_decimal_places_0/__init__.py | 1 +
.../test_two_decimal_places.py | 46 +++++++++----------
.../two_decimal_places.py | 5 +-
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/kyu_8/formatting_decimal_places_0/__init__.py b/kyu_8/formatting_decimal_places_0/__init__.py
index e69de29bb2d..1ced7a92204 100644
--- a/kyu_8/formatting_decimal_places_0/__init__.py
+++ b/kyu_8/formatting_decimal_places_0/__init__.py
@@ -0,0 +1 @@
+"""Formatting decimal places #0."""
diff --git a/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py b/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py
index d25a74b52da..057315550ba 100644
--- a/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py
+++ b/kyu_8/formatting_decimal_places_0/test_two_decimal_places.py
@@ -1,5 +1,6 @@
"""
-Test for -> Formatting decimal places #0
+Test for -> Formatting decimal places #0.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.formatting_decimal_places_0.two_decimal_places \
import two_decimal_places
@@ -29,14 +31,21 @@
name='Source/Kata')
# pylint: enable=R0801
class TwoDecimalPlacesTestCase(unittest.TestCase):
- """
- Testing two_decimal_places function
- """
+ """Testing two_decimal_places function."""
- def test_two_decimal_places(self):
+ @parameterized.expand([
+ (4.659725356,
+ 4.66,
+ "didn't work for 4.659725356"),
+ (173735326.3783732637948948,
+ 173735326.38,
+ "didn't work for 173735326.3783732637948948"),
+ (4.653725356,
+ 4.65,
+ "didn't work for 4.653725356")])
+ def test_two_decimal_places(self, n, expected, msg):
"""
- Testing two_decimal_places function
- with various test inputs.
+ Testing two_decimal_places function with various test inputs.
Each number should be formatted that it is
rounded to two decimal places. You don't
@@ -50,25 +59,12 @@ def test_two_decimal_places(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
with allure.step("Pass a number and verify the output"):
- data: tuple = (
- (4.659725356,
- 4.66,
- "didn't work for 4.659725356"),
- (173735326.3783732637948948,
- 173735326.38,
- "didn't work for 173735326.3783732637948948"),
- (4.653725356,
- 4.65,
- "didn't work for 4.653725356"))
-
- for n, expected, msg in data:
- print_log(n=n, expected=expected)
- self.assertEqual(expected,
- two_decimal_places(n),
- msg)
+ print_log(n=n, expected=expected)
+ self.assertEqual(expected, two_decimal_places(n), msg)
diff --git a/kyu_8/formatting_decimal_places_0/two_decimal_places.py b/kyu_8/formatting_decimal_places_0/two_decimal_places.py
index f6202d3bd6c..43822163c39 100644
--- a/kyu_8/formatting_decimal_places_0/two_decimal_places.py
+++ b/kyu_8/formatting_decimal_places_0/two_decimal_places.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Formatting decimal places #0
+Solution for -> Formatting decimal places #0.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,6 +8,8 @@
def two_decimal_places(n: float) -> float:
"""
+ Convert a number into decimal.
+
Each number should be formatted that it is
rounded to two decimal places. You don't
need to check whether the input is a valid
From 477fc50ae9a52a8b553cf3c8066fbba3649b8743 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 03:05:30 -0800
Subject: [PATCH 14/81] Grasshopper
---
.../grasshopper_check_for_factor/__init__.py | 1 +
.../check_for_factor.py | 6 +-
.../test_check_for_factor.py | 68 ++++++++-----------
3 files changed, 32 insertions(+), 43 deletions(-)
diff --git a/kyu_8/grasshopper_check_for_factor/__init__.py b/kyu_8/grasshopper_check_for_factor/__init__.py
index e69de29bb2d..e8573f8e858 100644
--- a/kyu_8/grasshopper_check_for_factor/__init__.py
+++ b/kyu_8/grasshopper_check_for_factor/__init__.py
@@ -0,0 +1 @@
+"""Grasshopper."""
diff --git a/kyu_8/grasshopper_check_for_factor/check_for_factor.py b/kyu_8/grasshopper_check_for_factor/check_for_factor.py
index 9073809a97c..b22755abbf9 100644
--- a/kyu_8/grasshopper_check_for_factor/check_for_factor.py
+++ b/kyu_8/grasshopper_check_for_factor/check_for_factor.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Grasshopper - Check for factor
+Solution for -> Grasshopper - Check for factor.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,8 +8,7 @@
def check_for_factor(base: int, factor: int) -> bool:
"""
- This function should test if the
- factor is a factor of base.
+ Check if the factor is a factor of base.
Factors are numbers you can multiply
together to get another number.
diff --git a/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py b/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py
index 52ace47678c..6b8597bb418 100644
--- a/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py
+++ b/kyu_8/grasshopper_check_for_factor/test_check_for_factor.py
@@ -1,5 +1,6 @@
"""
-Test for -> Grasshopper - Check for factor
+Test for -> Grasshopper - Check for factor.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.grasshopper_check_for_factor.check_for_factor \
import check_for_factor
@@ -29,11 +31,14 @@
name='Source/Kata')
# pylint: disable=R0801
class CheckForFactorTestCase(unittest.TestCase):
- """
- Testing check_for_factor function.
- """
-
- def test_check_for_factor_true(self):
+ """Testing check_for_factor function."""
+
+ @parameterized.expand([
+ (10, 2, True),
+ (63, 7, True),
+ (2450, 5, True),
+ (24612, 3, True)])
+ def test_check_for_factor_true(self, base, factor, expected):
"""
Testing check_for_factor function.
@@ -49,28 +54,22 @@ def test_check_for_factor_true(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
with allure.step("Return true if it is a factor"):
- data: tuple = (
- (10, 2, True),
- (63, 7, True),
- (2450, 5, True),
- (24612, 3, True))
-
- for base, factor, expected in data:
-
- print_log(base=base,
- factor=factor,
- expected=expected)
-
- self.assertEqual(expected,
- check_for_factor(base, factor))
-
- def test_check_for_factor_false(self):
+ print_log(base=base, factor=factor, expected=expected)
+ self.assertEqual(expected, check_for_factor(base, factor))
+
+ @parameterized.expand([
+ (9, 2, False),
+ (653, 7, False),
+ (2453, 5, False),
+ (24617, 3, False)])
+ def test_check_for_factor_false(self, base, factor, expected):
"""
Testing check_for_factor function.
@@ -86,23 +85,12 @@ def test_check_for_factor_false(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
with allure.step("Return false if it is not a factor"):
- data: tuple = (
- (9, 2, False),
- (653, 7, False),
- (2453, 5, False),
- (24617, 3, False))
-
- for base, factor, expected in data:
-
- print_log(base=base,
- factor=factor,
- expected=expected)
-
- self.assertEqual(expected,
- check_for_factor(base, factor))
+ print_log(base=base, factor=factor, expected=expected)
+ self.assertEqual(expected, check_for_factor(base, factor))
From a0dd26595fb3708c13dd945ada1b8b379c804314 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 03:10:40 -0800
Subject: [PATCH 15/81] # Grasshopper - Messi goals function
---
.../__init__.py | 1 +
.../messi_goals_function.py | 5 ++++-
.../test_messi_goals_function.py | 19 +++++++++++--------
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/kyu_8/grasshopper_messi_goals_function/__init__.py b/kyu_8/grasshopper_messi_goals_function/__init__.py
index e69de29bb2d..b041eb78383 100644
--- a/kyu_8/grasshopper_messi_goals_function/__init__.py
+++ b/kyu_8/grasshopper_messi_goals_function/__init__.py
@@ -0,0 +1 @@
+"""Grasshopper - Messi goals function."""
diff --git a/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py b/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py
index 439037ca19d..8891f8333af 100644
--- a/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py
+++ b/kyu_8/grasshopper_messi_goals_function/messi_goals_function.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Messi goals function
+Solution for -> Messi goals function.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,6 +8,8 @@
def goals(la_liga: int, copa_delrey: int, champions_league: int) -> int:
"""
+ Goals function.
+
The function returns Messi's total number
of goals in all three leagues:
- LaLiga
diff --git a/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py b/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py
index a69045f494d..faad955dd3d 100644
--- a/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py
+++ b/kyu_8/grasshopper_messi_goals_function/test_messi_goals_function.py
@@ -1,5 +1,6 @@
"""
-Test for -> Messi goals function
+Test for -> Messi goals function.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -26,14 +27,15 @@
name='Source/Kata')
# pylint: enable=R0801
class GoalsTestCase(unittest.TestCase):
- """
- Testing goals function
- """
+ """Testing goals function."""
def test_goals(self):
"""
- Verify that the function returns Messi's
- total number of goals in all three leagues.
+ Testing 'goals' function with various test data.
+
+ Verify that the function returns Messi's total
+ number of goals in all three leagues.
+
:return:
"""
# pylint: disable=R0801
@@ -41,8 +43,9 @@ def test_goals(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
From 19e631f47f1242af41c35ddb86b3854f2f5538ae Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 03:17:14 -0800
Subject: [PATCH 16/81] Personalized greeting
---
.../__init__.py | 1 +
.../grasshopper_personalized_message.py | 7 ++++---
.../test_grasshopper_personalized_message.py | 21 ++++++++++---------
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/kyu_8/grasshopper_personalized_message/__init__.py b/kyu_8/grasshopper_personalized_message/__init__.py
index e69de29bb2d..491c5af033c 100644
--- a/kyu_8/grasshopper_personalized_message/__init__.py
+++ b/kyu_8/grasshopper_personalized_message/__init__.py
@@ -0,0 +1 @@
+"""Grasshopper - Personalized Message."""
diff --git a/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py b/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py
index 32e43086b0f..2ffbc91f663 100644
--- a/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py
+++ b/kyu_8/grasshopper_personalized_message/grasshopper_personalized_message.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Personalized greeting
+Solution for -> Personalized greeting.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,9 +8,9 @@
def greet(name: str, owner: str) -> str:
"""
- Function that gives a personalized greeting.
- This function takes two parameters: name and owner.
+ Return a personalized greeting.
+ This function takes two parameters: name and owner.
:param name: str
:param owner: str
:return:
diff --git a/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py b/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py
index c7ebc2db024..a6ebc4e21a2 100644
--- a/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py
+++ b/kyu_8/grasshopper_personalized_message/test_grasshopper_personalized_message.py
@@ -1,5 +1,6 @@
"""
-Test for -> Personalized greeting
+Test for -> Personalized greeting.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -23,18 +24,17 @@
@allure.tag('FUNDAMENTALS',
'CONDITIONAL STATEMENTS',
'CONTROL FLOW')
-@allure.link(url='https://www.codewars.com/kata/5772da22b89313a4d50012f7',
- name='Source/Kata')
+@allure.link(
+ url='https://www.codewars.com/kata/5772da22b89313a4d50012f7',
+ name='Source/Kata')
# pylint: enable=R0801
class GreetTestCase(unittest.TestCase):
- """
- Testing greet function
- """
+ """Testing greet function."""
def test_greet(self):
"""
- Use conditionals to to verify that greet
- function returns the proper message.
+ Conditionals tests to verify that greet function returns the proper message.
+
:return:
"""
# pylint: disable=R0801
@@ -43,8 +43,9 @@ def test_greet(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
From 097e59ca172e3f260ed980d435c05910ce3c72a2 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 03:21:58 -0800
Subject: [PATCH 17/81] Grasshopper - Summation
---
kyu_8/grasshopper_summation/__init__.py | 1 +
kyu_8/grasshopper_summation/summation.py | 11 ++---
kyu_8/grasshopper_summation/test_summation.py | 42 +++++++++----------
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/kyu_8/grasshopper_summation/__init__.py b/kyu_8/grasshopper_summation/__init__.py
index e69de29bb2d..1afc95ba7c6 100644
--- a/kyu_8/grasshopper_summation/__init__.py
+++ b/kyu_8/grasshopper_summation/__init__.py
@@ -0,0 +1 @@
+"""Grasshopper - Summation."""
diff --git a/kyu_8/grasshopper_summation/summation.py b/kyu_8/grasshopper_summation/summation.py
index 244c2dd01d4..b0d76af18ef 100644
--- a/kyu_8/grasshopper_summation/summation.py
+++ b/kyu_8/grasshopper_summation/summation.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Grasshopper - Summation
+Solution for -> Grasshopper - Summation.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,12 +8,12 @@
def summation(num: int) -> int:
"""
- A program that finds the summation of every
- number from 1 to num.
+ Find the summation of every number from 1 to num.
+
The number will always be a positive
integer greater than 0.
- :param num:
- :return:
+ :param num: int
+ :return: int
"""
result: int = 0
for i in range(1, num + 1):
diff --git a/kyu_8/grasshopper_summation/test_summation.py b/kyu_8/grasshopper_summation/test_summation.py
index 888f66a3f9b..9463ac9c165 100644
--- a/kyu_8/grasshopper_summation/test_summation.py
+++ b/kyu_8/grasshopper_summation/test_summation.py
@@ -1,5 +1,6 @@
"""
-Test for -> Grasshopper - Summation
+Test for -> Grasshopper - Summation.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.grasshopper_summation.summation import summation
@@ -28,14 +30,18 @@
name='Source/Kata')
# pylint: enable=R0801
class SummationTestCase(unittest.TestCase):
- """
- Testing summation function
- """
+ """Testing summation function."""
- def test_summation(self):
+ @parameterized.expand([
+ (1, 1),
+ (8, 36),
+ (22, 253),
+ (100, 5050),
+ (213, 22791)])
+ def test_summation(self, num, expected):
"""
- Testing summation function
- with various test inputs
+ Testing summation function with various test inputs.
+
:return:
"""
# pylint: disable=R0801
@@ -43,21 +49,13 @@ def test_summation(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"")
# pylint: enable=R0801
- with allure.step("Enter number and verify the output"):
- test_data: tuple = (
- (1, 1),
- (8, 36),
- (22, 253),
- (100, 5050),
- (213, 22791))
-
- for d in test_data:
- num: int = d[0]
- expected: int = d[1]
- print_log(num=num, expected=expected)
- self.assertEqual(summation(num), expected)
+ with allure.step(f"Enter a number: {num} "
+ f"and verify the expected output: {expected}."):
+ print_log(num=num, expected=expected)
+ self.assertEqual(summation(num), expected)
From 033aef3a017ca38e50a6aa283bb860d0a6f3ea0f Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 03:39:31 -0800
Subject: [PATCH 18/81] # Greek Sort
---
kyu_8/greek_sort/__init__.py | 1 +
kyu_8/greek_sort/evaluator.py | 8 +++-
kyu_8/greek_sort/greek_comparator.py | 7 ++-
kyu_8/greek_sort/test_greek_comparator.py | 54 +++++++++++------------
4 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/kyu_8/greek_sort/__init__.py b/kyu_8/greek_sort/__init__.py
index e69de29bb2d..c7b87d9e076 100644
--- a/kyu_8/greek_sort/__init__.py
+++ b/kyu_8/greek_sort/__init__.py
@@ -0,0 +1 @@
+"""Greek Sort."""
diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py
index ed4a7f7f3f2..87ee1fa7f28 100644
--- a/kyu_8/greek_sort/evaluator.py
+++ b/kyu_8/greek_sort/evaluator.py
@@ -1,11 +1,15 @@
"""
-Evaluates the expression
+Evaluator function for -> Greek Sort.
+
+Created by Egor Kostan.
+GitHub: https://github.com/ikostan
"""
def evaluator(result: int, expected: str) -> bool:
"""
- Evaluator
+ Evaluator function.
+
:param result: int
:param expected: str
:return: bool
diff --git a/kyu_8/greek_sort/greek_comparator.py b/kyu_8/greek_sort/greek_comparator.py
index c3c6cb9665c..3be8ac276f6 100644
--- a/kyu_8/greek_sort/greek_comparator.py
+++ b/kyu_8/greek_sort/greek_comparator.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Greek Sort
+Solution for -> Greek Sort.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -15,10 +16,12 @@
def greek_comparator(lhs: str, rhs: str) -> int:
"""
+ Greek comparator function.
+
A custom comparison function of two arguments (iterable elements)
which should return a negative, zero or positive number depending
on whether the first argument is considered smaller than, equal to,
- or larger than the second argument
+ or larger than the second argument.
:param lhs: str
:param rhs: str
:return: int
diff --git a/kyu_8/greek_sort/test_greek_comparator.py b/kyu_8/greek_sort/test_greek_comparator.py
index e2f70debdf6..5213b0fc477 100644
--- a/kyu_8/greek_sort/test_greek_comparator.py
+++ b/kyu_8/greek_sort/test_greek_comparator.py
@@ -1,5 +1,6 @@
"""
-Test for -> Greek Sort
+Test for -> Greek Sort.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from kyu_8.greek_sort.greek_comparator import greek_comparator
from kyu_8.greek_sort.evaluator import evaluator
from utils.log_func import print_log
@@ -24,14 +26,16 @@
url='https://www.codewars.com/kata/56bc1acf66a2abc891000561',
name='Source/Kata')
class GreekComparatorTestCase(unittest.TestCase):
- """
- Testing greek_comparator function
- """
+ """Testing greek_comparator function."""
- def test_greek_comparator(self):
+ @parameterized.expand([
+ ('alpha', 'beta', '< 0'),
+ ('psi', 'psi', '== 0'),
+ ('upsilon', 'rho', '> 0')])
+ def test_greek_comparator(self, lhs, rhs, expected):
"""
- Testing greek_comparator function
- with various test inputs
+ Testing greek_comparator function with various test inputs.
+
:return:
"""
# pylint: disable=R0801
@@ -39,8 +43,9 @@ def test_greek_comparator(self):
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'Codewars badge:
'
- ''
+ ''
'Test Description:
'
"Codewars badge:
'
+ ''
+ 'Test Description:
'
+ "")
+ # pylint: enable=R0801
+ with allure.step(f"Enter test data: {elevators} "
+ f"and verify the expected output: {expected}."):
+ left, right, call = elevators
+ result: str = elevator(left, right, call)
+ print_log(expected=expected, left=left, right=right, call=call)
+ message: str = f'elevators: {elevators}, result: {result}, expected: {expected}'
+ self.assertEqual(expected, result, msg=message)
From aa02db4e8d1a5a634aacb28eb35102d3328caf04 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 04:26:24 -0800
Subject: [PATCH 21/81] Update closest_elevator.py
Using config file /home/runner/work/codewars/codewars/.pylintrc
************* Module kyu_8.closest_elevator.closest_elevator
kyu_8/closest_elevator/closest_elevator.py:24:0: C0305: Trailing newlines (trailing-newlines)
---
kyu_8/closest_elevator/closest_elevator.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/kyu_8/closest_elevator/closest_elevator.py b/kyu_8/closest_elevator/closest_elevator.py
index d7a14647c98..3a04743db19 100644
--- a/kyu_8/closest_elevator/closest_elevator.py
+++ b/kyu_8/closest_elevator/closest_elevator.py
@@ -21,4 +21,3 @@ def elevator(left: int, right: int, call: int) -> str:
return 'left'
return 'right'
-
From 2e5bc5ab72b314e268a2377e277bfd2f1f93bc8e Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 04:27:44 -0800
Subject: [PATCH 22/81] Update requirements.txt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Issues to fix by upgrading dependencies:
Upgrade jinja2@3.1.4 to jinja2@3.1.5 to fix
✗ Template Injection (new) [Medium Severity][https://security.snyk.io/vuln/SNYK-PYTHON-JINJA2-8548181] in jinja2@3.1.4
introduced by jinja2@3.1.4 and 2 other path(s)
✗ Improper Neutralization (new) [Medium Severity][https://security.snyk.io/vuln/SNYK-PYTHON-JINJA2-8548987] in jinja2@3.1.4
introduced by jinja2@3.1.4 and 2 other path(s)
---
requirements.txt | Bin 2808 -> 2808 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644
GIT binary patch
delta 14
Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM
delta 14
Vcmew%`a^UB6APosW@eVJYyc?^1iJtL
From 8e5724aa2a5e2349dd40ac7bdcf474f61b9d4402 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 04:33:30 -0800
Subject: [PATCH 23/81] Update requirements.txt
---
requirements.txt | Bin 2808 -> 2808 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644
GIT binary patch
delta 14
Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM
delta 14
Vcmew%`a^UB6APosW@eVJYyc?^1iJtL
From 07c185194fafa24406c8848740e1489f52982dce Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 04:50:24 -0800
Subject: [PATCH 24/81] # Holiday VI - Shark Pontoon
---
kyu_8/holiday_vi_shark_pontoon/__init__.py | 1 +
kyu_8/holiday_vi_shark_pontoon/shark.py | 6 ++++--
kyu_8/holiday_vi_shark_pontoon/test_shark.py | 16 +++++++++-------
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/kyu_8/holiday_vi_shark_pontoon/__init__.py b/kyu_8/holiday_vi_shark_pontoon/__init__.py
index e69de29bb2d..d2ec6b21e8c 100644
--- a/kyu_8/holiday_vi_shark_pontoon/__init__.py
+++ b/kyu_8/holiday_vi_shark_pontoon/__init__.py
@@ -0,0 +1 @@
+"""Holiday VI - Shark Pontoon."""
diff --git a/kyu_8/holiday_vi_shark_pontoon/shark.py b/kyu_8/holiday_vi_shark_pontoon/shark.py
index c1b97b07c7b..2decb2b5b55 100644
--- a/kyu_8/holiday_vi_shark_pontoon/shark.py
+++ b/kyu_8/holiday_vi_shark_pontoon/shark.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Holiday VI - Shark Pontoon
+Solution for -> Holiday VI - Shark Pontoon.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -11,6 +12,8 @@ def shark(pontoon_distance,
shark_speed,
dolphin) -> str:
"""
+ Shark function.
+
You are given 5 variables: sharkDistance = distance the shark
needs to cover to eat you in metres, sharkSpeed = how fast it
can move in metres/second, pontoonDistance = how far you need
@@ -19,7 +22,6 @@ def shark(pontoon_distance,
the swimming speed of the shark as the dolphin will attack it.
If you make it, return "Alive!", if not, return "Shark Bait!".
-
:param pontoon_distance:
:param shark_distance:
:param you_speed:
diff --git a/kyu_8/holiday_vi_shark_pontoon/test_shark.py b/kyu_8/holiday_vi_shark_pontoon/test_shark.py
index 712bc97e21c..350946571f7 100644
--- a/kyu_8/holiday_vi_shark_pontoon/test_shark.py
+++ b/kyu_8/holiday_vi_shark_pontoon/test_shark.py
@@ -1,5 +1,6 @@
"""
-Test for -> Holiday VI - Shark Pontoon
+Test for -> Holiday VI - Shark Pontoon.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -26,13 +27,12 @@
url='https://www.codewars.com/kata/57e921d8b36340f1fd000059',
name='Source/Kata')
class SharkTestCase(unittest.TestCase):
- """
- Testing shark function
- """
+ """Testing shark function."""
def test_shark_alive_1(self):
"""
- Testing shark function -> positive
+ Testing shark function -> positive #1.
+
:return:
"""
# pylint: disable=R0801
@@ -66,7 +66,8 @@ def test_shark_alive_1(self):
def test_shark_alive_2(self):
"""
- Testing shark function -> positive
+ Testing shark function -> positive #2.
+
:return:
"""
# pylint: disable=R0801
@@ -100,7 +101,8 @@ def test_shark_alive_2(self):
def test_shark_bait(self):
"""
- Testing shark function -> negative
+ Testing shark function -> negative.
+
:return:
"""
# pylint: disable=R0801
From d20c550085305dd2e1d6070c75e98a2c28de8f3d Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 05:00:15 -0800
Subject: [PATCH 25/81] kyu_8 docs
---
docs/kyu_8/kyu_8.closest_elevator.rst | 32 +++++++++++++++++++++++++++
docs/kyu_8/kyu_8.greek_sort.rst | 10 ++++-----
docs/kyu_8/kyu_8.rst | 2 +-
3 files changed, 38 insertions(+), 6 deletions(-)
create mode 100644 docs/kyu_8/kyu_8.closest_elevator.rst
diff --git a/docs/kyu_8/kyu_8.closest_elevator.rst b/docs/kyu_8/kyu_8.closest_elevator.rst
new file mode 100644
index 00000000000..87d8946ffa8
--- /dev/null
+++ b/docs/kyu_8/kyu_8.closest_elevator.rst
@@ -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:
diff --git a/docs/kyu_8/kyu_8.greek_sort.rst b/docs/kyu_8/kyu_8.greek_sort.rst
index 8d34ffa8d2d..640c357c1c5 100644
--- a/docs/kyu_8/kyu_8.greek_sort.rst
+++ b/docs/kyu_8/kyu_8.greek_sort.rst
@@ -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:
diff --git a/docs/kyu_8/kyu_8.rst b/docs/kyu_8/kyu_8.rst
index 4ebf3f9ed13..de518e18f07 100644
--- a/docs/kyu_8/kyu_8.rst
+++ b/docs/kyu_8/kyu_8.rst
@@ -7,10 +7,10 @@ Subpackages
.. toctree::
:maxdepth: 4
- kyu_8.readme
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
From 6d62247f082be9c2e769394bb02f3f0f6ecb4c99 Mon Sep 17 00:00:00 2001
From: Egor Kostan <20955183+ikostan@users.noreply.github.com>
Date: Tue, 24 Dec 2024 05:07:38 -0800
Subject: [PATCH 26/81] # Is it a palindrome
---
kyu_8/is_it_a_palindrome/__init__.py | 1 +
kyu_8/is_it_a_palindrome/is_palindrome.py | 7 ++-
.../is_it_a_palindrome/test_is_palindrome.py | 52 +++++++++----------
3 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/kyu_8/is_it_a_palindrome/__init__.py b/kyu_8/is_it_a_palindrome/__init__.py
index e69de29bb2d..d96511f544b 100644
--- a/kyu_8/is_it_a_palindrome/__init__.py
+++ b/kyu_8/is_it_a_palindrome/__init__.py
@@ -0,0 +1 @@
+"""Is it a palindrome."""
diff --git a/kyu_8/is_it_a_palindrome/is_palindrome.py b/kyu_8/is_it_a_palindrome/is_palindrome.py
index 0e0afcb961b..88ba9606d18 100644
--- a/kyu_8/is_it_a_palindrome/is_palindrome.py
+++ b/kyu_8/is_it_a_palindrome/is_palindrome.py
@@ -1,5 +1,6 @@
"""
-Solution for -> Is it a palindrome?
+Solution for -> Is it a palindrome?.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -7,8 +8,10 @@
def is_palindrome(s: str) -> bool:
"""
+ Palindrome testing function.
+
Write function isPalindrome that checks if
- a given string (case insensitive) is a palindrome.
+ a given string (case-insensitive) is a palindrome.
:param s: str
:return: bool
"""
diff --git a/kyu_8/is_it_a_palindrome/test_is_palindrome.py b/kyu_8/is_it_a_palindrome/test_is_palindrome.py
index 71fea953daf..5d28ea002fe 100644
--- a/kyu_8/is_it_a_palindrome/test_is_palindrome.py
+++ b/kyu_8/is_it_a_palindrome/test_is_palindrome.py
@@ -1,5 +1,6 @@
"""
-Test for -> Is it a palindrome?
+Test for -> Is it a palindrome?.
+
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
@@ -8,6 +9,7 @@
import unittest
import allure
+from parameterized import parameterized
from utils.log_func import print_log
from kyu_8.is_it_a_palindrome.is_palindrome import is_palindrome
@@ -25,18 +27,28 @@
name='Source/Kata')
# pylint: enable=R0801
class IsPalindromeTestCase(unittest.TestCase):
- """
- Testing is_palindrome function
- """
+ """Testing is_palindrome function."""
- def test_is_palindrome(self):
+ @parameterized.expand([
+ ('a', True),
+ ('aba', True),
+ ('Abba', True),
+ ('malam', True),
+ ('walter', False),
+ ('kodok', True),
+ ('Kasue', False),
+ ('NdjXglGnYGKhQtuAcxNWFwVRZZDMrFmiOPMZsvr', False),
+ ('XqmUTaAmrrYitgNwkCwaWdFYsEhfIeOohViba', False),
+ ('ZtItThFBUPCSCbtcUfDwXzyajhRIWioUHpVzN', False),
+ ('XqNeuBjbshHwqjoUNGHhVRolqxWRRWYYbN', False)])
+ def test_is_palindrome(self, string, expected):
"""
- Testing is_palindrome function
- with various test inputs
+ Testing is_palindrome function with various test inputs.
The function should check if a
- given string (case insensitive)
+ given string (case-insensitive)
is a palindrome.
+ :return:
"""
# pylint: disable=R0801
allure.dynamic.title("Testing is_palindrome function")
@@ -46,22 +58,10 @@ def test_is_palindrome(self):
''
'Test Description:
'
- "")
-
- with allure.step("Enter test string and verify the output"):
- test_data: tuple = (
- ('a', True),
- ('aba', True),
- ('Abba', True),
- ('malam', True),
- ('walter', False),
- ('kodok', True),
- ('Kasue', False),
- ('NdjXglGnYGKhQtuAcxNWFwVRZZDMrFmiOPMZsvr', False),
- ('XqmUTaAmrrYitgNwkCwaWdFYsEhfIeOohViba', False),
- ('ZtItThFBUPCSCbtcUfDwXzyajhRIWioUHpVzN', False),
- ('XqNeuBjbshHwqjoUNGHhVRolqxWRRWYYbN', False))
+ "Codewars badge:
'
- ''
+ ''
'Test Description:
'
- "")
+ "
" + "The function should return true if you are employed and " + "not on vacation (because these are the circumstances under " + "which you need to set an alarm). It should return false " + "otherwise." + '
' + ''
+ 'Examples:'
+ '
'
+ 'setAlarm(true, true) -> false
'
+ 'setAlarm(false, true) -> false
'
+ 'setAlarm(false, false) -> false
'
+ 'setAlarm(true, false) -> true
'
+ "
The player rolls the dice and moves the number" + "of spaces indicated by the dice two times.
" + "Pass position and roll and compare the output" + "to the expected result.
") # pylint: enable=R0801 with allure.step("Test start position zero"): position: int = 0 From f7652d870c7e8682d02bb2c20e78cefbacae25e6 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:03:43 -0800 Subject: [PATCH 38/81] The Feast of Many Beasts. --- kyu_8/the_feast_of_many_beasts/__init__.py | 1 + kyu_8/the_feast_of_many_beasts/feast.py | 7 ++-- kyu_8/the_feast_of_many_beasts/test_feast.py | 38 +++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/kyu_8/the_feast_of_many_beasts/__init__.py b/kyu_8/the_feast_of_many_beasts/__init__.py index e69de29bb2d..affe7c98b82 100644 --- a/kyu_8/the_feast_of_many_beasts/__init__.py +++ b/kyu_8/the_feast_of_many_beasts/__init__.py @@ -0,0 +1 @@ +"""The Feast of Many Beasts.""" diff --git a/kyu_8/the_feast_of_many_beasts/feast.py b/kyu_8/the_feast_of_many_beasts/feast.py index d32a6f57b4c..f57febf2c20 100644 --- a/kyu_8/the_feast_of_many_beasts/feast.py +++ b/kyu_8/the_feast_of_many_beasts/feast.py @@ -1,5 +1,6 @@ """ -Solution for -> The Feast of Many Beasts +Solution for -> The Feast of Many Beasts. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,9 @@ def feast(beast: str, dish: str) -> bool: """ - A function feast that takes the animal's name and + 'feast' function. + + A function that takes the animal's name and dish as arguments and returns true or false to indicate whether the beast is allowed to bring the dish to the feast. diff --git a/kyu_8/the_feast_of_many_beasts/test_feast.py b/kyu_8/the_feast_of_many_beasts/test_feast.py index 4e71ede1a98..7e3c9344973 100644 --- a/kyu_8/the_feast_of_many_beasts/test_feast.py +++ b/kyu_8/the_feast_of_many_beasts/test_feast.py @@ -1,5 +1,6 @@ """ -Test for -> The Feast of Many Beasts +Test for -> The Feast of Many Beasts. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,29 +27,12 @@ name='Source/Kata') # pylint: enable=R0801 class FeastTestCase(unittest.TestCase): - """ - Testing 'feast' function - """ + """Testing 'feast' function.""" def test_feast(self): """ - Testing 'feast' function with various test inputs - - Testing a function feast that takes the animal's - name and dish as arguments and returns true or - false to indicate whether the beast is allowed - to bring the dish to the feast. - - Assume that beast and dish are always lowercase strings, - and that each has at least two letters. beast and dish - may contain hyphens and spaces, but these will not appear - at the beginning or end of the string. They will not - contain numerals. + Testing 'feast' function with various test inputs. - There is just one rule: the dish must start and end with - the same letters as the animal's name. For example, the - great blue heron is bringing garlic naan and the chickadee - is bringing chocolate cake. :return: """ # pylint: disable=R0801 @@ -59,7 +43,19 @@ def test_feast(self): '' 'Testing a function feast that takes the animal's " + "name and dish as arguments and returns true or " + "false to indicate whether the beast is allowed " + "to bring the dish to the feast.
" + "Assume that beast and dish are always lowercase strings, " + "and that each has at least two letters. beast and dish " + "may contain hyphens and spaces, but these will not appear " + "at the beginning or end of the string. They will not " + "contain numerals.
" + "There is just one rule: the dish must start and end with " + "the same letters as the animal's name. For example, the " + "great blue heron is bringing garlic naan and the chickadee " + "is bringing chocolate cake.
") # pylint: enable=R0801 with allure.step("Enter animal's name and dish " "as arguments and assert the output"): From ea578389c99fa8544b9048df6732b2ff9d06f274 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:07:52 -0800 Subject: [PATCH 39/81] Third Angle of a Triangle. --- kyu_8/third_angle_of_triangle/__init__.py | 1 + .../test_third_angle_of_triangle.py | 38 ++++++------------- .../third_angle_of_triangle.py | 5 ++- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/kyu_8/third_angle_of_triangle/__init__.py b/kyu_8/third_angle_of_triangle/__init__.py index e69de29bb2d..5f11b606f95 100644 --- a/kyu_8/third_angle_of_triangle/__init__.py +++ b/kyu_8/third_angle_of_triangle/__init__.py @@ -0,0 +1 @@ +"""Third Angle of a Triangle.""" diff --git a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py index c1cceafebcc..353637dacae 100644 --- a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py @@ -1,5 +1,6 @@ """ -Test for -> Third Angle of a Triangle +Test for -> Third Angle of a Triangle. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -26,14 +27,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class OtherAngleTestCase(unittest.TestCase): - """ - Testing other_angle - """ + """Testing other_angle function.""" def test_other_angle(self): """ - You are given two angles (in degrees) of a triangle. - Find the 3rd. + Testing other_angle function with various test data. + :return: """ # pylint: disable-msg=R0801 @@ -44,28 +43,21 @@ def test_other_angle(self): '' 'You are given two angles (in degrees) of a triangle." + "Find the 3rd.
") # pylint: enable-msg=R0801 with allure.step("Enter values of two angles and return the 3rd"): a: int = 30 b: int = 60 expected: int = 90 - - print_log(a=a, - b=b, - expected=expected) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) with allure.step("Enter values of two angles and return the 3rd"): a = 60 b = 60 expected = 60 - - print_log(a=a, - b=b, - expected=expected) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) self.assertEqual(other_angle(60, 60), 60) @@ -73,20 +65,12 @@ def test_other_angle(self): a = 43 b = 78 expected = 59 - - print_log(a=a, - b=b, - expected=expected) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) with allure.step("Enter values of two angles and return the 3rd"): a = 10 b = 20 expected = 150 - - print_log(a=a, - b=b, - expected=expected) - + print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) diff --git a/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py index 4be2862e8a5..560700e45e0 100644 --- a/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/third_angle_of_triangle.py @@ -1,5 +1,6 @@ """ -Solution for -> Third Angle of a Triangle +Solution for -> Third Angle of a Triangle. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def other_angle(a: int, b: int) -> int: """ + Calculate 3rd angle. + You are given two angles (in degrees) of a triangle. Write a function to return the 3rd. Note: only positive integers will be tested. From 36b83c29fe81c9964662da8cf5a146af1d576864 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:13:09 -0800 Subject: [PATCH 40/81] Well of Ideas - Easy Version --- kyu_8/well_of_ideas_easy_version/__init__.py | 1 + .../test_well_of_ideas_easy_version.py | 30 +++++++++---------- .../well_of_ideas_easy_version.py | 8 ++--- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/kyu_8/well_of_ideas_easy_version/__init__.py b/kyu_8/well_of_ideas_easy_version/__init__.py index e69de29bb2d..c4a87c311a7 100644 --- a/kyu_8/well_of_ideas_easy_version/__init__.py +++ b/kyu_8/well_of_ideas_easy_version/__init__.py @@ -0,0 +1 @@ +"""Well of Ideas - Easy Version.""" diff --git a/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py b/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py index 98a48f7b720..a176416565b 100644 --- a/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py +++ b/kyu_8/well_of_ideas_easy_version/test_well_of_ideas_easy_version.py @@ -1,5 +1,6 @@ """ -Tests for -> Well of Ideas - Easy Version +Tests for -> Well of Ideas - Easy Version. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,14 +30,12 @@ name='Source/Kata') # pylint: enable=R0801 class WellTestCase(unittest.TestCase): - """ - Testing well function - """ + """Testing 'well' function.""" def test_well_fail(self): """ - If there are no good ideas, - as is often the case, return 'Fail!'. + If there are no good ideas, as is often the case, return 'Fail!'. + :return: """ # pylint: disable=R0801 @@ -44,10 +43,11 @@ def test_well_fail(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'If there are no good ideas, return 'Fail!'.
") # pylint: enable=R0801 with allure.step("Pass list with no 'good' in it"): lst: list = ['bad', 'bad', 'bad'] @@ -57,8 +57,8 @@ def test_well_fail(self): def test_well_publish(self): """ - If there are one or two good ideas, - return 'Publish!', + If there are one or two good ideas, return 'Publish!'. + :return: """ # pylint: disable=R0801 @@ -69,7 +69,7 @@ def test_well_publish(self): '' 'If there are one or two good ideas, return 'Publish!'
") # pylint: enable=R0801 with allure.step("Pass list with one 'good' in it"): lst: list = ['good', 'bad', 'bad', 'bad', 'bad'] @@ -79,8 +79,8 @@ def test_well_publish(self): def test_well_series(self): """ - if there are more than 2 return - 'I smell a series!'. + If there are more than 2 return 'I smell a series!'. + :return: """ # pylint: disable=R0801 @@ -91,7 +91,7 @@ def test_well_series(self): '' 'If there are more than 2 return 'I smell a series!'
") # pylint: enable=R0801 with allure.step("Pass list with more than 2 'good' in it"): lst: list = ['good', 'bad', 'bad', diff --git a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py index 1537dd77892..c8a19a9490d 100644 --- a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py +++ b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py @@ -1,5 +1,6 @@ """ -Solution for -> Well of Ideas - Easy Version +Solution for -> Well of Ideas - Easy Version. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,9 +10,8 @@ def well(x: List[str]) -> str: """ - If there are one or two good ideas, return 'Publish!'. - If there are more than 2 return 'I smell a series!'. - If there are no good ideas, return 'Fail!'. + 'well' function + :param x: List[str] :return: str """ From 6b9f1b33d6fd806d2c0aa55f8b8d6bb6571645e5 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:17:39 -0800 Subject: [PATCH 41/81] Will there be enough space?. --- kyu_8/will_there_be_enough_space/__init__.py | 1 + kyu_8/will_there_be_enough_space/enough.py | 3 +- .../will_there_be_enough_space/test_enough.py | 55 ++++++++----------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/kyu_8/will_there_be_enough_space/__init__.py b/kyu_8/will_there_be_enough_space/__init__.py index e69de29bb2d..dfef7dcb40f 100644 --- a/kyu_8/will_there_be_enough_space/__init__.py +++ b/kyu_8/will_there_be_enough_space/__init__.py @@ -0,0 +1 @@ +"""Will there be enough space.""" diff --git a/kyu_8/will_there_be_enough_space/enough.py b/kyu_8/will_there_be_enough_space/enough.py index aac42941813..3ed26defd6f 100644 --- a/kyu_8/will_there_be_enough_space/enough.py +++ b/kyu_8/will_there_be_enough_space/enough.py @@ -1,5 +1,6 @@ """ -Solution for -> Will there be enough space? +Solution for -> Will there be enough space?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_8/will_there_be_enough_space/test_enough.py b/kyu_8/will_there_be_enough_space/test_enough.py index cb537d703fd..fe941f70f34 100644 --- a/kyu_8/will_there_be_enough_space/test_enough.py +++ b/kyu_8/will_there_be_enough_space/test_enough.py @@ -1,5 +1,6 @@ """ -Tests for -> Will there be enough space? +Tests for -> Will there be enough space?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.will_there_be_enough_space.enough import enough @@ -26,46 +28,37 @@ name='Source/Kata') # pylint: enable=R0801 class EnoughTestCase(unittest.TestCase): - """ - Testing enough function - """ + """Testing enough function.""" - def test_enough(self): + @parameterized.expand([ + ((10, 5, 5), 0), + ((100, 60, 50), 10), + ((20, 5, 5), 0)]) + def test_enough(self, test_dat, expected): """ - Testing enough function - with various test data + Testing enough function with various test data. - If there is enough space, return 0, - and if there isn't, return the number - of passengers he can't take. :return: """ # pylint: disable=R0801 - allure.dynamic.title("STesting enough function") + allure.dynamic.title("Testing enough function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'If there is enough space, return 0, " + "and if there isn't, return the number " + "of passengers he can't take.
") # pylint: enable=R0801 - with allure.step("Enter test data and " - "verify the output"): - test_data: tuple = ( - ((10, 5, 5), 0), - ((100, 60, 50), 10), - ((20, 5, 5), 0)) - - for test_dat, expected in test_data: - cap: int = test_dat[0] - on: int = test_dat[1] - wait: int = test_dat[2] - - print_log(cap=cap, - on=on, - wait=wait, - expected=expected) - - self.assertEqual(expected, - enough(cap, on, wait)) + with allure.step(f"Enter test data: {test_dat} " + f"and verify the expected output: {expected}."): + cap: int = test_dat[0] + on: int = test_dat[1] + wait: int = test_dat[2] + print_log(cap=cap, + on=on, + wait=wait, + expected=expected) + self.assertEqual(expected, enough(cap, on, wait)) From 309a6ef0d8e131161be12c69dbd41bfc0e29d9ce Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:22:43 -0800 Subject: [PATCH 42/81] # Will you make it --- kyu_8/will_you_make_it/README.md | 2 +- kyu_8/will_you_make_it/__init__.py | 1 + kyu_8/will_you_make_it/test_zero_fuel.py | 49 +++++++++++------------- kyu_8/will_you_make_it/zero_fuel.py | 10 +++-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/kyu_8/will_you_make_it/README.md b/kyu_8/will_you_make_it/README.md index 609ab919f9f..1daf2e24c9d 100644 --- a/kyu_8/will_you_make_it/README.md +++ b/kyu_8/will_you_make_it/README.md @@ -1,4 +1,4 @@ -# Will you make it +# Will you make it? You were camping with your friends far away from home, but when it's time to go back, you realize that you fuel is running out diff --git a/kyu_8/will_you_make_it/__init__.py b/kyu_8/will_you_make_it/__init__.py index e69de29bb2d..8c9870dbbff 100644 --- a/kyu_8/will_you_make_it/__init__.py +++ b/kyu_8/will_you_make_it/__init__.py @@ -0,0 +1 @@ +"""Will you make it?.""" diff --git a/kyu_8/will_you_make_it/test_zero_fuel.py b/kyu_8/will_you_make_it/test_zero_fuel.py index 6ef2863739f..25be63c50e0 100644 --- a/kyu_8/will_you_make_it/test_zero_fuel.py +++ b/kyu_8/will_you_make_it/test_zero_fuel.py @@ -1,5 +1,6 @@ """ -Tests for -> Will you make it? +Tests for -> Will you make it?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from kyu_8.will_you_make_it.zero_fuel import zero_fuel from utils.log_func import print_log @@ -28,13 +30,15 @@ name='Source/Kata') # pylint: enable=R0801 class ZeroFuelTestCase(unittest.TestCase): - """ - Testing zero_fuel - """ + """Testing zero_fuel function.""" - def test_zero_fuel(self): + @parameterized.expand([ + ((50, 25, 2), True), + ((100, 50, 1), False)]) + def test_zero_fuel(self, data, expected): """ - Testing the function with various test data + Testing the function with various test data. + :return: """ # pylint: disable=R0801 @@ -42,8 +46,9 @@ def test_zero_fuel(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'You were camping with your friends far away from home, " "but when it's time to go back, you realize that you fuel " @@ -51,23 +56,13 @@ def test_zero_fuel(self): "know that on average, your car runs on about 25 miles per " "gallon. There are 2 gallons left. Considering these factors, " "write a function that tells you if it is possible to get to " - "the pump or not. Function should return true (1 in Prolog) if " - "it is possible and false (0 in Prolog) if not. The input values " - "are always positive.
") + "the pump or not. Function should return true (1 in Prolog) " + "if it is possible and false (0 in Prolog) if not. The input " + "values are always positive.") # pylint: enable=R0801 - test_data: tuple = ( - ((50, 25, 2), True), - ((100, 50, 1), False)) - - for data, expected in test_data: - actual_result = zero_fuel(data[0], data[1], data[2]) - with allure.step(f"Enter data ({data}) and verify the " - f"expected output ({expected}) " - f"vs actual result ({actual_result})"): - - print_log(data=data, - expected=expected, - result=actual_result) - - self.assertEqual(expected, - actual_result) + actual_result = zero_fuel(data[0], data[1], data[2]) + with allure.step(f"Enter data ({data}) and verify the " + f"expected output ({expected}) " + f"vs actual result ({actual_result})"): + print_log(data=data, expected=expected, result=actual_result) + self.assertEqual(expected, actual_result) diff --git a/kyu_8/will_you_make_it/zero_fuel.py b/kyu_8/will_you_make_it/zero_fuel.py index dfdc00d6572..0e97db3fb85 100644 --- a/kyu_8/will_you_make_it/zero_fuel.py +++ b/kyu_8/will_you_make_it/zero_fuel.py @@ -1,12 +1,17 @@ """ -Solution for -> Will you make it? +Solution for -> Will you make it?. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ -def zero_fuel(distance_to_pump: int, mpg: int, fuel_left: int) -> bool: +def zero_fuel(distance_to_pump: int, + mpg: int, + fuel_left: int) -> bool: """ + 'zero_fuel' function. + You were camping with your friends far away from home, but when it's time to go back, you realize that you fuel is running out and the nearest pump is 50 miles away! @@ -16,7 +21,6 @@ def zero_fuel(distance_to_pump: int, mpg: int, fuel_left: int) -> bool: to get to the pump or not. Function should return true (1 in Prolog) if it is possible and false (0 in Prolog) if not. The input values are always positive. - :param distance_to_pump: int :param mpg: int :param fuel_left: int From 746f6d160bb312ac31de0cf1ac1845728f5f4e09 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:29:35 -0800 Subject: [PATCH 43/81] A wolf in sheep's clothing. --- kyu_8/wolf_in_sheep_clothing/__init__.py | 1 + .../test_wolf_in_sheep_clothing.py | 28 +++++++++++++------ .../wolf_in_sheep_clothing.py | 6 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/kyu_8/wolf_in_sheep_clothing/__init__.py b/kyu_8/wolf_in_sheep_clothing/__init__.py index e69de29bb2d..6833659fbbf 100644 --- a/kyu_8/wolf_in_sheep_clothing/__init__.py +++ b/kyu_8/wolf_in_sheep_clothing/__init__.py @@ -0,0 +1 @@ +"""A wolf in sheep's clothing.""" diff --git a/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py b/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py index 5fd1ee09df0..b7f440e2cea 100644 --- a/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py +++ b/kyu_8/wolf_in_sheep_clothing/test_wolf_in_sheep_clothing.py @@ -1,5 +1,6 @@ """ -Tests for -> A wolf in sheep's clothing +Tests for -> A wolf in sheep's clothing. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -24,16 +25,17 @@ 'ARRAYS', 'LOOPS', 'CONTROL FLOW') -@allure.link(url='https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15', - name='Source/Kata') +@allure.link( + url='https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15', + name='Source/Kata') # pylint: enable=R0801 class WarnTheSheepTestCase(unittest.TestCase): - """ - Testing warn_the_sheep function - """ + """Testing warn_the_sheep function.""" def test_warn_the_sheep_wolf_at_start(self): """ + Test the 'warn' func when the wolf in the beginning. + If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". :return: @@ -46,7 +48,8 @@ def test_warn_the_sheep_wolf_at_start(self): '' 'If the wolf is the closest animal to you, " + "return \"Pls go away and stop eating my sheep\".
") # pylint: enable=R0801 lst: list = ['wolf', 'sheep', 'sheep', 'sheep', 'sheep', 'sheep', @@ -60,6 +63,8 @@ def test_warn_the_sheep_wolf_at_start(self): def test_warn_the_sheep_wolf_in_middle(self): """ + Test the 'warn' func when the wolf in the middle. + If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". :return: @@ -72,7 +77,8 @@ def test_warn_the_sheep_wolf_in_middle(self): '' 'If the wolf is the closest animal to you, " + "return \"Pls go away and stop eating my sheep\".
") # pylint: enable=R0801 # 1 lst: list = ['sheep', 'sheep', 'sheep', @@ -107,6 +113,8 @@ def test_warn_the_sheep_wolf_in_middle(self): def test_warn_the_sheep_wolf_at_end(self): """ + Test the 'warn' func when the wolf in the end. + If the wolf is not the closest animal to you, return "Oi! Sheep number N! You are about to be eaten by a wolf!" where N is the sheep's position in the queue. @@ -120,7 +128,9 @@ def test_warn_the_sheep_wolf_at_end(self): '' 'If the wolf is not the closest animal to you, " + "return \"Oi! Sheep number N! You are about to be eaten by a wolf!\" " + "where N is the sheep's position in the queue.
") # pylint: enable=R0801 lst: list = ['sheep', 'sheep', 'wolf'] expected: str = 'Pls go away and stop eating my sheep' diff --git a/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py b/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py index 7057389988e..628457e199f 100644 --- a/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py +++ b/kyu_8/wolf_in_sheep_clothing/wolf_in_sheep_clothing.py @@ -1,5 +1,6 @@ """ -Solution for -> A wolf in sheep's clothing +Solution for -> A wolf in sheep's clothing. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,8 +8,7 @@ def warn_the_sheep(queue: list) -> str: """ - Warn the sheep in front of the wolf - that it is about to be eaten. + Warn the sheep in front of the wolf. If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". From 5083d4504bc8dca7c59f15a91d803b3f96c92086 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:36:31 -0800 Subject: [PATCH 44/81] # Keep Hydrated --- kyu_8/keep_hydrated/__init__.py | 1 + kyu_8/keep_hydrated/keep_hydrated.py | 5 ++- kyu_8/keep_hydrated/test_keep_hydrated.py | 48 +++++++++++++---------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/kyu_8/keep_hydrated/__init__.py b/kyu_8/keep_hydrated/__init__.py index e69de29bb2d..7240da1b8cc 100644 --- a/kyu_8/keep_hydrated/__init__.py +++ b/kyu_8/keep_hydrated/__init__.py @@ -0,0 +1 @@ +"""Keep Hydrated.""" diff --git a/kyu_8/keep_hydrated/keep_hydrated.py b/kyu_8/keep_hydrated/keep_hydrated.py index 454ab57d457..a1bf20807cb 100644 --- a/kyu_8/keep_hydrated/keep_hydrated.py +++ b/kyu_8/keep_hydrated/keep_hydrated.py @@ -1,5 +1,6 @@ """ -Solution for -> Keep Hydrated! +Solution for -> Keep Hydrated!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def litres(time) -> int: """ + 'litres' function. + Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. diff --git a/kyu_8/keep_hydrated/test_keep_hydrated.py b/kyu_8/keep_hydrated/test_keep_hydrated.py index e8e64b29b50..54f73cc6f56 100644 --- a/kyu_8/keep_hydrated/test_keep_hydrated.py +++ b/kyu_8/keep_hydrated/test_keep_hydrated.py @@ -1,5 +1,6 @@ """ -Test for -> Keep Hydrated! +Test for -> Keep Hydrated!. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.keep_hydrated.keep_hydrated import litres @@ -28,13 +30,20 @@ name='Source/Kata') # pylint: disable=R0801 class KeepHydratedTestCase(unittest.TestCase): - """ - Testing litres function - """ + """Testing litres function.""" - def test_keep_hydrated(self): + @parameterized.expand([ + (2, 1, 'should return 1 litre'), + (1.4, 0, 'should return 0 litres'), + (12.3, 6, 'should return 6 litres'), + (0.82, 0, 'should return 0 litres'), + (11.8, 5, 'should return 5 litres'), + (1787, 893, 'should return 893 litres'), + (0, 0, 'should return 0 litres')]) + def test_keep_hydrated(self, hours, expected, message): """ - Testing litres function with various test inputs + Testing litres function with various test inputs. + :return: """ # pylint: disable=R0801 @@ -45,18 +54,17 @@ def test_keep_hydrated(self): '' '" + "Because Nathan knows it is important to stay hydrated, " + " he drinks 0.5 litres of water per hour of cycling." + "
" + "" + "You get given the time in hours and you need to return " + "the number of litres Nathan will drink, rounded " + "to the smallest value." + "
") # pylint: enable=R0801 - with allure.step("Enter hours and verify the output"): - test_data: tuple = ( - (2, 1, 'should return 1 litre'), - (1.4, 0, 'should return 0 litres'), - (12.3, 6, 'should return 6 litres'), - (0.82, 0, 'should return 0 litres'), - (11.8, 5, 'should return 5 litres'), - (1787, 893, 'should return 893 litres'), - (0, 0, 'should return 0 litres')) - - for hours, expected, message in test_data: - print_log(hours=hours, expected=expected) - self.assertEqual(expected, litres(hours), message) + with allure.step(f"Enter hours: {hours} " + f"and verify the expected output: {expected}."): + print_log(hours=hours, expected=expected) + self.assertEqual(expected, litres(hours), message) From fd0ddb59f22d921f530c518920692a964099f809 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:39:01 -0800 Subject: [PATCH 45/81] Update evaluator.py kyu_8/greek_sort/evaluator.py:10 in public function `evaluator`: D401: First line should be in imperative mood (perhaps 'Evaluate', not 'Evaluator') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index 87ee1fa7f28..f32ba347cc9 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - Evaluator function. + 'evaluator' function. :param result: int :param expected: str From d08cdaac2d08001162f5e2c8ac11b895b8de9f86 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:39:52 -0800 Subject: [PATCH 46/81] Update make_upper_case.py kyu_8/make_upper_case/make_upper_case.py:10 in public function `make_upper_case`: D401: First line should be in imperative mood; try rephrasing (found 'Function') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/make_upper_case/make_upper_case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/make_upper_case/make_upper_case.py b/kyu_8/make_upper_case/make_upper_case.py index 29dc55c42db..b2dd792edbb 100644 --- a/kyu_8/make_upper_case/make_upper_case.py +++ b/kyu_8/make_upper_case/make_upper_case.py @@ -8,7 +8,7 @@ def make_upper_case(s: str) -> str: """ - Function that convert to UpperCase. + Convert to UpperCase. :param s: str :return: str From f32c8cdb607d33a280ca03fa9542fa22f0e358ca Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:40:57 -0800 Subject: [PATCH 47/81] Update enough.py kyu_8/will_there_be_enough_space/enough.py:10 in public function `enough`: D401: First line should be in imperative mood; try rephrasing (found 'The') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/will_there_be_enough_space/enough.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyu_8/will_there_be_enough_space/enough.py b/kyu_8/will_there_be_enough_space/enough.py index 3ed26defd6f..c320e23d1e7 100644 --- a/kyu_8/will_there_be_enough_space/enough.py +++ b/kyu_8/will_there_be_enough_space/enough.py @@ -8,6 +8,8 @@ def enough(cap: int, on: int, wait: int) -> int: """ + 'enough' function. + The driver wants you to write a simple program telling him if he will be able to fit all the passengers. @@ -19,7 +21,6 @@ def enough(cap: int, on: int, wait: int) -> int: cap is the amount of people the bus can hold excluding the driver. on is the number of people on the bus. wait is the number of people waiting to get on to the bus. - :param cap: int :param on: int :param wait: int From aced1dbeddf112653683ae9e145b5163b8391539 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:45:14 -0800 Subject: [PATCH 48/81] keep_up_the_hoop kyu_8/keep_up_the_hoop/hoop_count.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/hoop_count.py:1 at module level: D400: First line should end with a period (not 'p') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/hoop_count.py:9 in public function `hoop_count`: D401: First line should be in imperative mood; try rephrasing (found 'A') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". kyu_8/keep_up_the_hoop/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/keep_up_the_hoop/test_hoop_count.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/test_hoop_count.py:1 at module level: D400: First line should end with a period (not 'p') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:28 in public class `HoopCountTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/keep_up_the_hoop/test_hoop_count.py:28 in public class `HoopCountTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:33 in public method `test_hoop_count_positive`: D400: First line should end with a period (not ')') The [first line of a] docstring is a phrase ending in a period. kyu_8/keep_up_the_hoop/test_hoop_count.py:66 in public method `test_hoop_count_negative`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/keep_up_the_hoop/test_hoop_count.py:66 in public method `test_hoop_count_negative`: D400: First line should end with a period (not ')') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/keep_up_the_hoop/__init__.py | 1 + kyu_8/keep_up_the_hoop/hoop_count.py | 8 +++++--- kyu_8/keep_up_the_hoop/test_hoop_count.py | 19 +++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/kyu_8/keep_up_the_hoop/__init__.py b/kyu_8/keep_up_the_hoop/__init__.py index e69de29bb2d..c1749419584 100644 --- a/kyu_8/keep_up_the_hoop/__init__.py +++ b/kyu_8/keep_up_the_hoop/__init__.py @@ -0,0 +1 @@ +"""Keep up the hoop.""" diff --git a/kyu_8/keep_up_the_hoop/hoop_count.py b/kyu_8/keep_up_the_hoop/hoop_count.py index bff4cedf9a5..9badc57f057 100644 --- a/kyu_8/keep_up_the_hoop/hoop_count.py +++ b/kyu_8/keep_up_the_hoop/hoop_count.py @@ -1,5 +1,6 @@ """ -Solution -> Keep up the hoop +Solution -> Keep up the hoop. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,9 +8,10 @@ def hoop_count(n: int) -> str: """ - A program where Alex can input (n) how many times the - hoop goes round and it will return him an encouraging message + 'hoop_count' function. + A program where Alex can input (n) how many times the + hoop goes round, and it will return him an encouraging message :param n: int :return: str """ diff --git a/kyu_8/keep_up_the_hoop/test_hoop_count.py b/kyu_8/keep_up_the_hoop/test_hoop_count.py index ee377488e2d..fa5ae53c944 100644 --- a/kyu_8/keep_up_the_hoop/test_hoop_count.py +++ b/kyu_8/keep_up_the_hoop/test_hoop_count.py @@ -1,5 +1,6 @@ """ -Test -> Keep up the hoop +Test -> Keep up the hoop. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -25,22 +26,19 @@ name='Source/Kata') # pylint: enable=R0801 class HoopCountTestCase(unittest.TestCase): - """ - Testing hoop_count function - """ + """Testing hoop_count function.""" def test_hoop_count_positive(self): """ - Testing hoop_count function (positive) + Testing hoop_count function (positive). - Alex just got a new hula hoop, he loves it but feels + Alex just got a new hula-hoop, he loves it but feels discouraged because his little brother is better than him Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message - 10 or more hoops, return "Great, now move on to tricks". - - Not 10 hoops, return "Keep at it until you get it". :return: @@ -54,7 +52,7 @@ def test_hoop_count_positive(self): '' 'Testing hoop_count function (positive).
") # pylint: enable=R0801 with allure.step("Enter n and verify the result"): n: int = 11 @@ -64,7 +62,8 @@ def test_hoop_count_positive(self): def test_hoop_count_negative(self): """ - Testing hoop_count function (negative) + Testing hoop_count function (negative). + :return: """ # pylint: disable=R0801 @@ -76,7 +75,7 @@ def test_hoop_count_negative(self): '' 'Testing hoop_count function (negative).
") # pylint: enable=R0801 with allure.step("Enter n and verify the result"): n: int = 3 From 78a128e27cf12ed9da745b57446791be23ba96a3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:53:05 -0800 Subject: [PATCH 49/81] logical_calculator kyu_8/logical_calculator/test_logical_calculator.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:1 at module level: D400: First line should end with a period (not 'r') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:30 in public class `LogicalCalculatorTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/logical_calculator/test_logical_calculator.py:30 in public class `LogicalCalculatorTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:35 in public method `test_logical_calc_and`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:35 in public method `test_logical_calc_and`: D400: First line should end with a period (not 'l') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:99 in public method `test_logical_calc_or`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:99 in public method `test_logical_calc_or`: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/test_logical_calculator.py:157 in public method `test_logical_calc_xor`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/test_logical_calculator.py:157 in public method `test_logical_calc_xor`: D400: First line should end with a period (not 'a') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/logical_calculator/logical_calculator.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/logical_calculator/logical_calculator.py:1 at module level: D400: First line should end with a period (not 'r') The [first line of a] docstring is a phrase ending in a period. kyu_8/logical_calculator/logical_calculator.py:9 in public function `logical_calc`: D401: First line should be in imperative mood (perhaps 'Calculate', not 'Calculates') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/logical_calculator/__init__.py | 1 + .../logical_calculator/logical_calculator.py | 3 +- .../test_logical_calculator.py | 42 +++++++++++-------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/kyu_8/logical_calculator/__init__.py b/kyu_8/logical_calculator/__init__.py index e69de29bb2d..ef9d65f99ea 100644 --- a/kyu_8/logical_calculator/__init__.py +++ b/kyu_8/logical_calculator/__init__.py @@ -0,0 +1 @@ +"""Logical calculator.""" diff --git a/kyu_8/logical_calculator/logical_calculator.py b/kyu_8/logical_calculator/logical_calculator.py index 4bcf26788e6..f3dda92d72c 100644 --- a/kyu_8/logical_calculator/logical_calculator.py +++ b/kyu_8/logical_calculator/logical_calculator.py @@ -1,5 +1,6 @@ """ -Solution for -> Logical Calculator +Solution for -> Logical Calculator. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_8/logical_calculator/test_logical_calculator.py b/kyu_8/logical_calculator/test_logical_calculator.py index 7f4e11cc220..875e0f8bfa1 100644 --- a/kyu_8/logical_calculator/test_logical_calculator.py +++ b/kyu_8/logical_calculator/test_logical_calculator.py @@ -1,5 +1,6 @@ """ -Test for -> Logical Calculator +Test for -> Logical Calculator. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,21 +28,17 @@ name='Source/Kata') # pylint: enable=R0801 class LogicalCalculatorTestCase(unittest.TestCase): - """ - Testing logical_calc function - """ + """Testing logical_calc function.""" def test_logical_calc_and(self): """ - And (∧) is the truth-functional - operator of logical conjunction + And (∧) is the truth-functional operator of logical conjunction. - The and of a set of operands is true + The 'and' of a set of operands is true if and only if all of its operands are true. Source: https://en.wikipedia.org/wiki/Logical_conjunction - :return: """ # pylint: disable=R0801 @@ -49,10 +46,13 @@ def test_logical_calc_and(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'The 'and' of a set of operands is true " + "if and only if all of its operands are true." + "
") # pylint: enable=R0801 with allure.step("Pass an array with 2 members (negative)"): lst: list = [True, False] @@ -97,11 +97,13 @@ def test_logical_calc_and(self): def test_logical_calc_or(self): """ + Testing 'or'. + In logic and mathematics, or is the truth-functional operator of (inclusive) disjunction, also known as alternation. - The or of a set of operands is true if + The 'or' of a set of operands is true if and only if one or more of its operands is true. Source: @@ -117,7 +119,10 @@ def test_logical_calc_or(self): '' '" + "The 'or' of a set of operands is true if " + "and only if one or more of its operands is true." + "
") # pylint: enable=R0801 with allure.step('Pass an array with 2 members (positive)'): lst: list = [True, False] @@ -155,7 +160,9 @@ def test_logical_calc_or(self): def test_logical_calc_xor(self): """ - Exclusive or or exclusive disjunction is a + Testing 'XOR'. + + Exclusive or exclusive disjunction is a logical operation that outputs true only when inputs differ (one is true, the other is false). @@ -170,10 +177,11 @@ def test_logical_calc_xor(self): allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( 'XOR outputs true whenever the inputs differ.
") # pylint: enable=R0801 with allure.step('Pass an array with 2 members (positive)'): lst: list = [True, False] From 50e4ef2108082365f7b5592363459b67b4aa7e84 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:56:50 -0800 Subject: [PATCH 50/81] is_your_period_late kyu_8/is_your_period_late/__init__.py:1 at module level: D104: Missing docstring in public package All modules should normally have docstrings. [...] all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. Note: Public (exported) definitions are either those with names listed in __all__ variable (if present), or those that do not start with a single underscore. kyu_8/is_your_period_late/test_is_your_period_late.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:1 at module level: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:30 in public class `PeriodIsLateTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/is_your_period_late/test_is_your_period_late.py:30 in public class `PeriodIsLateTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:35 in public method `test_period_is_late_positive`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:35 in public method `test_period_is_late_positive`: D400: First line should end with a period (not 's') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/test_is_your_period_late.py:98 in public method `test_period_is_late_negative`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/test_is_your_period_late.py:98 in public method `test_period_is_late_negative`: D400: First line should end with a period (not 's') The [first line of a] docstring is a phrase ending in a period. kyu_8/is_your_period_late/is_your_period_late.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_8/is_your_period_late/is_your_period_late.py:1 at module level: D400: First line should end with a period (not 'e') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/is_your_period_late/__init__.py | 1 + .../is_your_period_late/is_your_period_late.py | 3 ++- .../test_is_your_period_late.py | 17 +++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/kyu_8/is_your_period_late/__init__.py b/kyu_8/is_your_period_late/__init__.py index e69de29bb2d..0328c3963b9 100644 --- a/kyu_8/is_your_period_late/__init__.py +++ b/kyu_8/is_your_period_late/__init__.py @@ -0,0 +1 @@ +"""Is your period late.""" diff --git a/kyu_8/is_your_period_late/is_your_period_late.py b/kyu_8/is_your_period_late/is_your_period_late.py index 122f68b50c8..c310e5f4213 100644 --- a/kyu_8/is_your_period_late/is_your_period_late.py +++ b/kyu_8/is_your_period_late/is_your_period_late.py @@ -1,5 +1,6 @@ """ -Solution for -> Is your period late +Solution for -> Is your period late. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_8/is_your_period_late/test_is_your_period_late.py b/kyu_8/is_your_period_late/test_is_your_period_late.py index eb75b23032f..b47b73b21f7 100644 --- a/kyu_8/is_your_period_late/test_is_your_period_late.py +++ b/kyu_8/is_your_period_late/test_is_your_period_late.py @@ -1,5 +1,6 @@ """ -Test for -> Is your period late +Test for -> Is your period late. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -27,13 +28,12 @@ name='Source/Kata') # pylint: enable=R0801 class PeriodIsLateTestCase(unittest.TestCase): - """ - Testing period_is_late function - """ + """Testing period_is_late function.""" def test_period_is_late_positive(self): """ - Positive tests + Positive tests. + :return: """ # pylint: disable=R0801 @@ -44,7 +44,7 @@ def test_period_is_late_positive(self): '' 'Positive tests.
") # pylint: enable=R0801 with allure.step("Pass last, today and period length"): last: date = date(2016, 6, 13) @@ -96,7 +96,8 @@ def test_period_is_late_positive(self): def test_period_is_late_negative(self): """ - Negative tests + Negative tests. + :return: """ # pylint: disable=R0801 @@ -107,7 +108,7 @@ def test_period_is_late_negative(self): '' 'Negative tests.
") # pylint: enable=R0801 with allure.step("Pass last, today and period length"): last: date = date(2016, 6, 13) From 8c1169305f3c4bbc032f949b5b050d90adafd41d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 07:59:48 -0800 Subject: [PATCH 51/81] set_alarm kyu_8/set_alarm/test_set_alarm.py:31 in public class `SetAlarmTestCase`: D200: One-line docstring should fit on one line with quotes (found 3) The closing quotes are on the same line as the opening quotes. This looks better for one-liners. kyu_8/set_alarm/test_set_alarm.py:31 in public class `SetAlarmTestCase`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. kyu_8/set_alarm/test_set_alarm.py:49 in public method `test_set_alarm`: D412: No blank lines allowed between a section header and its content ('Examples') --- kyu_8/set_alarm/test_set_alarm.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kyu_8/set_alarm/test_set_alarm.py b/kyu_8/set_alarm/test_set_alarm.py index 8343922b702..6e3d5820cb7 100644 --- a/kyu_8/set_alarm/test_set_alarm.py +++ b/kyu_8/set_alarm/test_set_alarm.py @@ -28,9 +28,7 @@ name='Source/Kata') # pylint: enable=R0801 class SetAlarmTestCase(unittest.TestCase): - """ - Testing set_alarm function - """ + """Testing set_alarm function.""" @parameterized.expand([ ((True, True), @@ -54,7 +52,7 @@ def test_set_alarm(self, test_input, expected, msg): under which you need to set an alarm). It should return false otherwise. - Examples: + Examples setAlarm(true, true) -> false setAlarm(false, true) -> false From 341a31f4e27032903f79ebe80091ff64d77fad66 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:01:24 -0800 Subject: [PATCH 52/81] Update test_set_alarm.py kyu_8/set_alarm/test_set_alarm.py:47 in public method `test_set_alarm`: D412: No blank lines allowed between a section header and its content ('Examples') --- kyu_8/set_alarm/test_set_alarm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kyu_8/set_alarm/test_set_alarm.py b/kyu_8/set_alarm/test_set_alarm.py index 6e3d5820cb7..0b0643f102f 100644 --- a/kyu_8/set_alarm/test_set_alarm.py +++ b/kyu_8/set_alarm/test_set_alarm.py @@ -52,8 +52,7 @@ def test_set_alarm(self, test_input, expected, msg): under which you need to set an alarm). It should return false otherwise. - Examples - + Examples: setAlarm(true, true) -> false setAlarm(false, true) -> false setAlarm(false, false) -> false From 6532bb53f6204d492f4e6de77c53e278dca0794e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:02:13 -0800 Subject: [PATCH 53/81] Update logical_calculator.py kyu_8/logical_calculator/logical_calculator.py:10 in public function `logical_calc`: D401: First line should be in imperative mood (perhaps 'Calculate', not 'Calculates') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/logical_calculator/logical_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/logical_calculator.py b/kyu_8/logical_calculator/logical_calculator.py index f3dda92d72c..39cfbe75614 100644 --- a/kyu_8/logical_calculator/logical_calculator.py +++ b/kyu_8/logical_calculator/logical_calculator.py @@ -8,7 +8,7 @@ def logical_calc(array: list, op: str) -> bool: """ - Calculates logical value of boolean array. + Calculate logical value of boolean array. Logical operations: AND, OR and XOR. From d908bcb9ca90643f4834007e9284289f56f5b6ca Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:03:15 -0800 Subject: [PATCH 54/81] Update check_exam.py kyu_8/check_the_exam/check_exam.py:37 in public function `char_processor`: D401: First line should be in imperative mood (perhaps 'Process', not 'Processing') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/check_the_exam/check_exam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/check_the_exam/check_exam.py b/kyu_8/check_the_exam/check_exam.py index 2651f359112..cf3d0a93805 100644 --- a/kyu_8/check_the_exam/check_exam.py +++ b/kyu_8/check_the_exam/check_exam.py @@ -35,7 +35,7 @@ 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 From ffff071cfec027379c483ac9cb8381e4594f845b Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:04:28 -0800 Subject: [PATCH 55/81] Update well_of_ideas_easy_version.py kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py:12 in public function `well`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. --- kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py index c8a19a9490d..637a8e19afb 100644 --- a/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py +++ b/kyu_8/well_of_ideas_easy_version/well_of_ideas_easy_version.py @@ -10,7 +10,7 @@ def well(x: List[str]) -> str: """ - 'well' function + 'well' function. :param x: List[str] :return: str From a6c59da57ad0f60a8e3d93e32e385445bcef6ba1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:06:32 -0800 Subject: [PATCH 56/81] Update evaluator.py kyu_8/greek_sort/evaluator.py:10 in public function `evaluator`: D401: First line should be in imperative mood (perhaps 'Evaluate', not 'evaluator') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index f32ba347cc9..e4bcc1e5f8e 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - 'evaluator' function. + Comparator for a list of phonetic words. :param result: int :param expected: str From 82c1c83d47375fdcfbda52ee1b88daa8bda2a186 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:09:10 -0800 Subject: [PATCH 57/81] Update evaluator.py --- kyu_8/greek_sort/evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/greek_sort/evaluator.py b/kyu_8/greek_sort/evaluator.py index e4bcc1e5f8e..908e2b3e7ff 100644 --- a/kyu_8/greek_sort/evaluator.py +++ b/kyu_8/greek_sort/evaluator.py @@ -8,7 +8,7 @@ def evaluator(result: int, expected: str) -> bool: """ - Comparator for a list of phonetic words. + Compare two arguments. :param result: int :param expected: str From 3f63da4e307bcbde9fee53f73eff09538dc24e42 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:22:01 -0800 Subject: [PATCH 58/81] Update test_third_angle_of_triangle.py --- kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py index 353637dacae..39f3e1622cd 100644 --- a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py @@ -59,7 +59,6 @@ def test_other_angle(self): expected = 60 print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) - self.assertEqual(other_angle(60, 60), 60) with allure.step("Enter values of two angles and return the 3rd"): a = 43 From f1d31ca43e92863ec6efd74a695a7d32f718c793 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:27:55 -0800 Subject: [PATCH 59/81] Update test_third_angle_of_triangle.py --- .../test_third_angle_of_triangle.py | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py index 39f3e1622cd..7066b65393e 100644 --- a/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py +++ b/kyu_8/third_angle_of_triangle/test_third_angle_of_triangle.py @@ -9,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_8.third_angle_of_triangle.third_angle_of_triangle \ import other_angle @@ -29,7 +30,12 @@ class OtherAngleTestCase(unittest.TestCase): """Testing other_angle function.""" - def test_other_angle(self): + @parameterized.expand([ + (30, 60, 90), + (60, 60, 60), + (43, 78, 59), + (10, 20, 150)]) + def test_other_angle(self, a, b, expected): """ Testing other_angle function with various test data. @@ -47,29 +53,5 @@ def test_other_angle(self): "Find the 3rd.") # pylint: enable-msg=R0801 with allure.step("Enter values of two angles and return the 3rd"): - a: int = 30 - b: int = 60 - expected: int = 90 - print_log(a=a, b=b, expected=expected) - self.assertEqual(other_angle(a, b), expected) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 60 - b = 60 - expected = 60 - print_log(a=a, b=b, expected=expected) - self.assertEqual(other_angle(a, b), expected) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 43 - b = 78 - expected = 59 - print_log(a=a, b=b, expected=expected) - self.assertEqual(other_angle(a, b), expected) - - with allure.step("Enter values of two angles and return the 3rd"): - a = 10 - b = 20 - expected = 150 print_log(a=a, b=b, expected=expected) self.assertEqual(other_angle(a, b), expected) From 73457ed871bbc9335b3d640571bdc0c8c3c646b8 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:36:40 -0800 Subject: [PATCH 60/81] pydocstyle for main --- .../workflows/lint_test_build_pipeline.yml | 3 + .github/workflows/pydocstyle.yml | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/pydocstyle.yml diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index 28eaad4cef4..f2cd7abf847 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -22,6 +22,9 @@ jobs: yamllint: name: YAML Lint uses: iKostanOrg/codewars/.github/workflows/yamllint.yml@master + pydocstyle: + name: PYDOCSTYLE Lint + uses: iKostanOrg/codewars/.github/workflows/pydocstyle.yml@master pytest: name: Unitest with pytest needs: diff --git a/.github/workflows/pydocstyle.yml b/.github/workflows/pydocstyle.yml new file mode 100644 index 00000000000..83134517527 --- /dev/null +++ b/.github/workflows/pydocstyle.yml @@ -0,0 +1,66 @@ +--- +name: pydocstyle + +on: # yamllint disable-line rule:truthy + 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 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 + # Pydocstyle testing (Guide) + # https://www.pydocstyle.org/en/stable/usage.html#cli-usage + - name: Doc style checking with pydocstyle for kyu_2 + run: | + pydocstyle --verbose --explain --count kyu_2 + - name: Doc style checking with pydocstyle for kyu_3 + run: | + pydocstyle --verbose --explain --count kyu_3 + - name: Doc style checking with pydocstyle for kyu_4 + run: | + pydocstyle --verbose --explain --count kyu_4 + - name: Doc style checking with pydocstyle for kyu_5 + run: | + pydocstyle --verbose --explain --count kyu_5 + - name: Doc style checking with pydocstyle for kyu_6 + run: | + pydocstyle --verbose --explain --count kyu_6 + - name: Doc style checking with pydocstyle for kyu_7 + run: | + pydocstyle --verbose --explain --count kyu_7 + - name: Doc style checking with pydocstyle for kyu_8 + run: | + pydocstyle --verbose --explain --count kyu_8 From 4e001d6e48d8eb9fed1ac50f18b4ef63c6055637 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:38:25 -0800 Subject: [PATCH 61/81] Update closest_elevator.py ./kyu_8/closest_elevator/closest_elevator.py:8:1: E302 expected 2 blank lines, found 1 def elevator(left: int, right: int, call: int) -> str: --- kyu_8/closest_elevator/closest_elevator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_8/closest_elevator/closest_elevator.py b/kyu_8/closest_elevator/closest_elevator.py index 3a04743db19..74c694ee278 100644 --- a/kyu_8/closest_elevator/closest_elevator.py +++ b/kyu_8/closest_elevator/closest_elevator.py @@ -5,6 +5,7 @@ GitHub: https://github.com/ikostan """ + def elevator(left: int, right: int, call: int) -> str: """ Return closest elevator number. From 86d4a41c9bee5baa3f68a8d3d3b85fb3106cc01a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:39:44 -0800 Subject: [PATCH 62/81] Update test_take.py ./kyu_8/enumerable_magic_25/test_take.py:65:27: E127 continuation line over-indented for visual indent n=n, ^ ./kyu_8/enumerable_magic_25/test_take.py:66:27: E127 continuation line over-indented for visual indent expected=expected, ^ ./kyu_8/enumerable_magic_25/test_take.py:67:27: E127 continuation line over-indented for visual indent result=actual_result) --- kyu_8/enumerable_magic_25/test_take.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kyu_8/enumerable_magic_25/test_take.py b/kyu_8/enumerable_magic_25/test_take.py index 97d7be1a043..7d94d7dee78 100644 --- a/kyu_8/enumerable_magic_25/test_take.py +++ b/kyu_8/enumerable_magic_25/test_take.py @@ -61,9 +61,9 @@ def test_take(self, arr, n, expected): f"expected output ({expected}) " f"vs actual result ({actual_result})"): - print_log(rr=arr, - n=n, - expected=expected, - result=actual_result) + print_log(arr=arr, + n=n, + expected=expected, + result=actual_result) self.assertEqual(expected, actual_result) From 47bab94c8e699dc8fc6ec8b1a3ab74a2fc8ec05a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:41:12 -0800 Subject: [PATCH 63/81] Update README.md Error: kyu_8/closest_elevator/README.md:21 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md --- kyu_8/closest_elevator/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/closest_elevator/README.md b/kyu_8/closest_elevator/README.md index 51e1fa33e81..51c872ea4ac 100644 --- a/kyu_8/closest_elevator/README.md +++ b/kyu_8/closest_elevator/README.md @@ -18,7 +18,7 @@ You can assume that the inputs will always be valid integers between 0-2. ## Examples -``` +```bash left right call result 0 1 0 "left" 0 1 1 "right" From 3b68c84f0c506299190700416b6e1b98e9853978 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:50:41 -0800 Subject: [PATCH 64/81] Update lint_test_build_pipeline.yml --- .github/workflows/lint_test_build_pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index f2cd7abf847..087bb2a7562 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -33,6 +33,7 @@ jobs: - markdown - mypy - yamllint + - pydocstyle uses: iKostanOrg/codewars/.github/workflows/pytest.yml@master codecov: name: Codecov GitHub Action From c8b9a8d1bffcc3c2d03f5d6ac3a82637f64eccb0 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:54:38 -0800 Subject: [PATCH 65/81] Update lint_test_build_pipeline.yml --- .github/workflows/lint_test_build_pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_test_build_pipeline.yml b/.github/workflows/lint_test_build_pipeline.yml index 087bb2a7562..8208a76196f 100644 --- a/.github/workflows/lint_test_build_pipeline.yml +++ b/.github/workflows/lint_test_build_pipeline.yml @@ -23,7 +23,7 @@ jobs: name: YAML Lint uses: iKostanOrg/codewars/.github/workflows/yamllint.yml@master pydocstyle: - name: PYDOCSTYLE Lint + name: PyDocStyle Lint uses: iKostanOrg/codewars/.github/workflows/pydocstyle.yml@master pytest: name: Unitest with pytest From 2f84a83a83ffe52bc8679deb14b84dc154e63673 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 24 Dec 2024 08:56:01 -0800 Subject: [PATCH 66/81] Update markdown_lint.yml --- .github/workflows/markdown_lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_lint.yml b/.github/workflows/markdown_lint.yml index 64a623ac2da..e857a509871 100644 --- a/.github/workflows/markdown_lint.yml +++ b/.github/workflows/markdown_lint.yml @@ -1,5 +1,5 @@ --- -name: 'Markdown Lint' +name: Markdown Lint on: # yamllint disable-line rule:truthy push: From 67146681851e9d11972fb5ee2a0dc086724e42d2 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:42:42 -0800 Subject: [PATCH 67/81] Update requirements.txt --- requirements.txt | Bin 2808 -> 2808 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index f29b41e793f444adba31aee864001ba5cceb0d46..0aa523925287de66ba0e7bede64343af62553236 100644 GIT binary patch delta 14 Vcmew%`a^UB6APp1W@eVJYyc?~1iSzM delta 14 Vcmew%`a^UB6APosW@eVJYyc?^1iJtL From c984b53130c64d354b0e60569f31b5f3011ddc48 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:06:13 -0800 Subject: [PATCH 68/81] Complete The Pattern #5 - Even Ladder --- kyu_7/coloured_triangles/test_triangle.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kyu_7/coloured_triangles/test_triangle.py b/kyu_7/coloured_triangles/test_triangle.py index 36dd38491bf..e947d6352f4 100644 --- a/kyu_7/coloured_triangles/test_triangle.py +++ b/kyu_7/coloured_triangles/test_triangle.py @@ -56,6 +56,16 @@ def test_triangle(self, string, expected): :return: """ + # pylint: disable-msg=R0801 + allure.dynamic.title("Basic test case for triangle func.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '" + "If n <= 1 then it should return "" (i.e. empty string)." + "
" + "" + "If any odd number is passed as argument then the pattern " + "should last up to the largest even number which is smaller " + "than the passed odd number." + "
") + # pylint: enable-msg=R0801 + with allure.step(f"Enter test number (n): {n} " + f"and verify the output: {expected}"): + result = pattern(n) + print_log(n=n, expected=expected, result=result) + self.assertEqual(expected, result, msg=expected) From d33aef18f329693657accfc776c2d8815e920021 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:39:27 -0800 Subject: [PATCH 70/81] Update solution.py --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index ac3c29be7c2..66d48f1b54e 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -16,13 +16,12 @@ def pattern(n: int) -> str: # If n <= 1 then it should return "" (i.e. empty string). if n < 2: return '' - #If any odd number is passed as argument then the pattern + # If any odd number is passed as argument then the pattern # should last up to the largest even number which is smaller # than the passed odd number. lines: list = [] for i in range(2, n + 1, 2): # Note: There are no spaces in the pattern. - line = (f'{i}' * i) - lines.append(line) + lines.append(f'{i}' * i) # Use \n in string to jump to next line. return '\n'.join(lines) From c5547335e8502066a87a1846d701cccb382bc86c Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:04:33 -0800 Subject: [PATCH 71/81] Create test_logical_calculator_error.py 90.41% (-0.39%) compared to 2f84a83 --- .../test_logical_calculator_error.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 kyu_8/logical_calculator/test_logical_calculator_error.py diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py new file mode 100644 index 00000000000..457640d57ba --- /dev/null +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -0,0 +1,62 @@ +""" +Test for -> Logical Calculator ValueError. + +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" + +# FUNDAMENTALS ARRAYS + +import unittest +import allure +import pytest +from utils.log_func import print_log +from kyu_8.logical_calculator.logical_calculator \ + import logical_calc + + +# pylint: disable=R0801 +@allure.epic('8 kyu') +@allure.parent_suite('Beginner') +@allure.suite("Data Structures") +@allure.sub_suite("Unit Tests") +@allure.feature("Lists") +@allure.story('Logical Calculator') +@allure.tag('FUNDAMENTALS', + 'ARRAYS' + "ValueError") +@allure.link( + url='https://www.codewars.com/kata/57096af70dad013aa200007b', + name='Source/Kata') +# pylint: enable=R0801 +class LogicalCalculatorValueErrorTestCase(unittest.TestCase): + """Testing ValueError.""" + + def test_logical_calc_value_error(self): + """ + Testing ValueError for logical_calc function. + :return: + """ + # pylint: disable=R0801 + allure.dynamic.title("Testing ValueError for logical_calc function.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '" + "Test Python Exception Handling Using 'pytest.raises'." + "
") + # pylint: enable=R0801 + with (allure.step("Pass an array with invalid operator.")): + arr: list = [] + op: str = 'RO' # invalid operator + operators: list = ['AND', 'OR', 'XOR'] + err = (f'ERROR: {op} is not a valid operator. ' + f'Please use one of the followings: {operators}') + with pytest.raises(ValueError) as calc_err: + logical_calc(arr, op) + self.assertEqual(str(calc_err.value), err) + From bee5ccc346208abdae8bda950405b84dbc3dd25d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:10:41 -0800 Subject: [PATCH 72/81] Update solution.py suggestion (code-quality): Convert for loop into list comprehension (list-comprehension) --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index 66d48f1b54e..cce9f20d504 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -19,9 +19,7 @@ def pattern(n: int) -> str: # If any odd number is passed as argument then the pattern # should last up to the largest even number which is smaller # than the passed odd number. - lines: list = [] - for i in range(2, n + 1, 2): - # Note: There are no spaces in the pattern. - lines.append(f'{i}' * i) + # Note: There are no spaces in the pattern.lines.append() # Use \n in string to jump to next line. + lines: list = [(f'{i}' * i) for i in range(2, n + 1, 2)] return '\n'.join(lines) From 372d14fa5605efcfec7b65a66236b17ccf913cd3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:16:40 -0800 Subject: [PATCH 73/81] Update test_pattern.py --- .../test_pattern.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py index ccf46073ca5..27d667468c3 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py @@ -37,7 +37,7 @@ class PatternTestCase(unittest.TestCase): (6, "22\n4444\n666666"), (0, ""), (-25, "")]) - def test_triangle(self, n, expected): + def test_pattern(self, n, expected): """ Basic test case for pattern func. @@ -65,3 +65,30 @@ def test_triangle(self, n, expected): result = pattern(n) print_log(n=n, expected=expected, result=result) self.assertEqual(expected, result, msg=expected) + + @parameterized.expand([ + (8, "22\n4444\n666666\n88888888")]) + def test_pattern_has_no_spaces(self, n, expected): + """ + Output should not have any spaces.. + + :return: + """ + # pylint: disable-msg=R0801 + allure.dynamic.title("Test no spaces in output.") + allure.dynamic.severity(allure.severity_level.NORMAL) + allure.dynamic.description_html( + '" + "There are no spaces in the pattern." + "
") + # pylint: enable-msg=R0801 + with allure.step(f"Enter test number (n): {n} " + "and verify the output has no spaces."): + result = pattern(n) + print_log(n=n, expected=expected, result=result) + self.assertEqual(result, expected) + self.assertEqual(result.count(' '), 0) From afa284ce040b1e9fe7720706e7b3d5a767cc4c2f Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:25:00 -0800 Subject: [PATCH 74/81] Update test_logical_calculator_error.py Trailing newlines kyu_8/logical_calculator/ test_logical_calculator_error.py 62 self.assertEqual(str(calc_err.value), err) --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 457640d57ba..56b92e06b2d 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -59,4 +59,3 @@ def test_logical_calc_value_error(self): with pytest.raises(ValueError) as calc_err: logical_calc(arr, op) self.assertEqual(str(calc_err.value), err) - From 947261ec4b2b0a30a4bd1bf49ea4f5672b0152cc Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:25:55 -0800 Subject: [PATCH 75/81] Update test_logical_calculator_error.py Unnecessary parens after 'with' keyword kyu_8/logical_calculator/ test_logical_calculator_error.py 51 "") 52 # pylint: enable=R0801 53 with (allure.step("Pass an array with invalid operator.")): 54 arr: list = [] 55 op: str = 'RO' # invalid operator --- kyu_8/logical_calculator/test_logical_calculator_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 56b92e06b2d..c35118a1c4c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -50,7 +50,7 @@ def test_logical_calc_value_error(self): "Test Python Exception Handling Using 'pytest.raises'." "") # pylint: enable=R0801 - with (allure.step("Pass an array with invalid operator.")): + with allure.step("Pass an array with invalid operator."): arr: list = [] op: str = 'RO' # invalid operator operators: list = ['AND', 'OR', 'XOR'] From 10e9323525d38f78669b8d5a4f5fcfd2a5926a62 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:26:43 -0800 Subject: [PATCH 76/81] Update test_logical_calculator_error.py Unused print_log imported from utils.log_func kyu_8/logical_calculator/ test_logical_calculator_error.py 13 from utils.log_func import print_log --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index c35118a1c4c..0378bc8575c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -10,7 +10,6 @@ import unittest import allure import pytest -from utils.log_func import print_log from kyu_8.logical_calculator.logical_calculator \ import logical_calc From cbdfe06a8366efe9e8387af537cd2948b6e5c380 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:44:55 -0800 Subject: [PATCH 77/81] Update solution.py ./kyu_7/complete_the_pattern_5_even_ladder/solution.py:8:1: E302 expected 2 blank lines, found 1 def pattern(n: int) -> str: ^ 1 E302 expected 2 blank lines, found 1 --- kyu_7/complete_the_pattern_5_even_ladder/solution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_7/complete_the_pattern_5_even_ladder/solution.py b/kyu_7/complete_the_pattern_5_even_ladder/solution.py index cce9f20d504..0cf706672e6 100644 --- a/kyu_7/complete_the_pattern_5_even_ladder/solution.py +++ b/kyu_7/complete_the_pattern_5_even_ladder/solution.py @@ -5,6 +5,7 @@ GitHub: https://github.com/ikostan """ + def pattern(n: int) -> str: """ 'pattern' function. From 8af04dfa2449bb6c14539d7efe7c6c7a7edab142 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:45:56 -0800 Subject: [PATCH 78/81] Update test_logical_calculator_error.py kyu_8/logical_calculator/test_logical_calculator_error.py:35 in public method `test_logical_calc_value_error`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. --- kyu_8/logical_calculator/test_logical_calculator_error.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 0378bc8575c..98bafed968c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -34,6 +34,7 @@ class LogicalCalculatorValueErrorTestCase(unittest.TestCase): def test_logical_calc_value_error(self): """ Testing ValueError for logical_calc function. + :return: """ # pylint: disable=R0801 From cb8aece05846248ba048c4b0caf1d11fd076364d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:48:16 -0800 Subject: [PATCH 79/81] Update test_logical_calculator_error.py --- kyu_8/logical_calculator/test_logical_calculator_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_8/logical_calculator/test_logical_calculator_error.py b/kyu_8/logical_calculator/test_logical_calculator_error.py index 98bafed968c..7564d32e74c 100644 --- a/kyu_8/logical_calculator/test_logical_calculator_error.py +++ b/kyu_8/logical_calculator/test_logical_calculator_error.py @@ -34,7 +34,7 @@ class LogicalCalculatorValueErrorTestCase(unittest.TestCase): def test_logical_calc_value_error(self): """ Testing ValueError for logical_calc function. - + :return: """ # pylint: disable=R0801 From e1efd56e214fb3ad44d9e5f03942af16f105c194 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 04:57:31 -0800 Subject: [PATCH 80/81] Create flake8_kyu8.yml --- .github/workflows/flake8_kyu8.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/flake8_kyu8.yml diff --git a/.github/workflows/flake8_kyu8.yml b/.github/workflows/flake8_kyu8.yml new file mode 100644 index 00000000000..1685c7f2aee --- /dev/null +++ b/.github/workflows/flake8_kyu8.yml @@ -0,0 +1,47 @@ +--- +name: Flake8 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 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_8 + flake8 --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics ./kyu_8 + # yamllint enable rule:line-length From 46af6a870b786636594fd875605d0082592960ed Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Wed, 25 Dec 2024 05:09:21 -0800 Subject: [PATCH 81/81] Create flake8_kyu7.yml --- .github/workflows/flake8_kyu7.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/flake8_kyu7.yml diff --git a/.github/workflows/flake8_kyu7.yml b/.github/workflows/flake8_kyu7.yml new file mode 100644 index 00000000000..f6c3ad57586 --- /dev/null +++ b/.github/workflows/flake8_kyu7.yml @@ -0,0 +1,47 @@ +--- +name: Flake8 for kyu7 + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'kyu7' + +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_7 + flake8 --count --max-complexity=10 --max-line-length=127 --benchmark --show-source --statistics ./kyu_7 + # yamllint enable rule:line-length