From a70ae43fe1b1a7b615449578e98d17e60a5d4b9e Mon Sep 17 00:00:00 2001 From: TheRealHaui Date: Wed, 12 Nov 2025 21:47:10 +0100 Subject: [PATCH 1/3] Added some Unit Tests to increase test code coverage --- other/fischer_yates_shuffle.py | 7 +++++++ scheduling/multi_level_feedback_queue.py | 2 +- strings/min_cost_string_conversion.py | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/other/fischer_yates_shuffle.py b/other/fischer_yates_shuffle.py index 5e90b10edd89..bc80e8f789c0 100644 --- a/other/fischer_yates_shuffle.py +++ b/other/fischer_yates_shuffle.py @@ -11,6 +11,13 @@ def fisher_yates_shuffle(data: list) -> list[Any]: + """ + >>> import random + >>> from unittest.mock import patch + >>> with patch('random.randint', side_effect=[0, 3, 1, 2, 2, 0, 3, 1]): + ... fisher_yates_shuffle(["python", "says", "hello", "!"]) + ['says', 'python', '!', 'hello'] + """ for _ in range(len(data)): a = random.randint(0, len(data) - 1) b = random.randint(0, len(data) - 1) diff --git a/scheduling/multi_level_feedback_queue.py b/scheduling/multi_level_feedback_queue.py index 58ba2afa0e67..93a0aada4e02 100644 --- a/scheduling/multi_level_feedback_queue.py +++ b/scheduling/multi_level_feedback_queue.py @@ -100,7 +100,7 @@ def calculate_completion_time(self, queue: list[Process]) -> list[int]: >>> P4 = Process("P4", 0, 24) >>> mlfq = MLFQ(3, [17, 25], deque([P1, P2, P3, P4]), 0) >>> _ = mlfq.multi_level_feedback_queue() - >>> mlfq.calculate_turnaround_time([P1, P2, P3, P4]) + >>> mlfq.calculate_completion_time([P1, P2, P3, P4]) [136, 34, 162, 125] """ completion_times = [] diff --git a/strings/min_cost_string_conversion.py b/strings/min_cost_string_conversion.py index 87eb5189e16a..f4e20e09fd5d 100644 --- a/strings/min_cost_string_conversion.py +++ b/strings/min_cost_string_conversion.py @@ -85,6 +85,8 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]: >>> y = len(ops[0]) - 1 >>> assemble_transformation(ops, x, y) ['Cc', 'Rau', 'Ct'] + >>> assemble_transformation(ops, x, y-1) + ['Cc', 'Da', 'Rtu'] >>> ops1 = [['0']] >>> x1 = len(ops1) - 1 From f79aefb875bf3538c314fd78b48dc2523175ec1f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 5 Sep 2026 21:31:51 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/special_numbers/kaprekar_constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/special_numbers/kaprekar_constant.py b/maths/special_numbers/kaprekar_constant.py index eb75108610de..d7bc7ba79a83 100644 --- a/maths/special_numbers/kaprekar_constant.py +++ b/maths/special_numbers/kaprekar_constant.py @@ -195,7 +195,7 @@ def main() -> None: print(f"Reached 6174 in {iterations} iteration(s)!") else: print("Number must be between 0 and 9999") - except (ValueError, EOFError): + except ValueError, EOFError: print("Invalid input or no input provided") From c4451baeff7cca0977dd9c9da6fe4663fb6d2740 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" Date: Sat, 5 Sep 2026 21:32:10 +0000 Subject: [PATCH 3/3] updating DIRECTORY.md --- DIRECTORY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index b59fed77f025..447a8c6df311 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -800,6 +800,8 @@ * [Happy Number](maths/special_numbers/happy_number.py) * [Harshad Numbers](maths/special_numbers/harshad_numbers.py) * [Hexagonal Number](maths/special_numbers/hexagonal_number.py) + * [Kaprekar Constant](maths/special_numbers/kaprekar_constant.py) + * [Kaprekar Number](maths/special_numbers/kaprekar_number.py) * [Krishnamurthy Number](maths/special_numbers/krishnamurthy_number.py) * [Perfect Number](maths/special_numbers/perfect_number.py) * [Polygonal Numbers](maths/special_numbers/polygonal_numbers.py)