File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
import random
2
2
from typing import List
3
3
4
+
4
5
def bogo_sort (collection : List [int ]) -> List [int ]:
5
6
"""Pure implementation of the bogosort algorithm in Python.
6
7
Bogosort generates random permutations until it guesses the correct one.
7
-
8
+
8
9
More info on: https://en.wikipedia.org/wiki/Bogosort
9
10
Args:
10
11
collection (List[int]): A mutable ordered collection with comparable items.
@@ -25,7 +26,7 @@ def bogo_sort(collection: List[int]) -> List[int]:
25
26
python -m doctest -v bogo_sort.py
26
27
or
27
28
python3 -m doctest -v bogo_sort.py
28
-
29
+
29
30
For manual testing, run:
30
31
python bogo_sort.py
31
32
"""
@@ -40,6 +41,7 @@ def is_sorted(collection: List[int]) -> bool:
40
41
random .shuffle (collection )
41
42
return collection
42
43
44
+
43
45
if __name__ == "__main__" :
44
46
user_input = input ("Enter numbers separated by a comma:\n " ).strip ()
45
47
unsorted = [int (item ) for item in user_input .split ("," )]
You can’t perform that action at this time.
0 commit comments