Skip to content

Commit ea09d1f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0653011 commit ea09d1f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

randomized_algorithms/miller_rabin_primality test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import random
22

3+
34
def miller_rabin_primality_test(n: int, k: int = 5) -> bool:
45
"""
56
Probabilistic primality test using Miller-Rabin algorithm.
@@ -46,6 +47,8 @@ def miller_rabin_primality_test(n: int, k: int = 5) -> bool:
4647
return False
4748
return True
4849

50+
4951
if __name__ == "__main__":
5052
import doctest
51-
doctest.testmod()
53+
54+
doctest.testmod()

randomized_algorithms/randomized_quicksort.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import random
22
from typing import List
33

4+
45
def randomized_quicksort(arr: List[int]) -> List[int]:
56
"""
67
Sorts a list of integers using randomized QuickSort algorithm.
@@ -25,6 +26,8 @@ def randomized_quicksort(arr: List[int]) -> List[int]:
2526
greater = [x for x in arr if x > pivot]
2627
return randomized_quicksort(less) + equal + randomized_quicksort(greater)
2728

29+
2830
if __name__ == "__main__":
2931
import doctest
30-
doctest.testmod()
32+
33+
doctest.testmod()

randomized_algorithms/reservoir_sampling.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
T = TypeVar("T")
55

6+
67
def reservoir_sampling(stream: Iterator[T], k: int) -> List[T]:
78
"""
89
Randomly select k items from a stream of unknown length using reservoir sampling.
@@ -29,6 +30,8 @@ def reservoir_sampling(stream: Iterator[T], k: int) -> List[T]:
2930
reservoir[j] = item
3031
return reservoir
3132

33+
3234
if __name__ == "__main__":
3335
import doctest
34-
doctest.testmod()
36+
37+
doctest.testmod()

0 commit comments

Comments
 (0)