Skip to content
Merged
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
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion maths/special_numbers/kaprekar_constant.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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")


Expand Down
7 changes: 7 additions & 0 deletions other/fischer_yates_shuffle.py
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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
Loading