Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions other/fischer_yates_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scheduling/multi_level_feedback_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 2 additions & 0 deletions strings/min_cost_string_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down