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