There was an error while loading. Please reload this page.
1 parent 9e3cd71 commit 4862428Copy full SHA for 4862428
1 file changed
sorts/pancake_sort.py
@@ -8,7 +8,7 @@
8
python pancake_sort.py
9
"""
10
11
-
+from __future__ import annotations
12
def pancake_sort(arr):
13
"""Sort Array with Pancake Sort.
14
:param arr: Collection containing comparable items
@@ -20,6 +20,9 @@ def pancake_sort(arr):
20
[]
21
>>> pancake_sort([-2, -5, -45])
22
[-45, -5, -2]
23
+
24
+ Time Complexity: (O(n^2))
25
+ Space Complexity: (O(n))
26
27
cur = len(arr)
28
while cur > 1:
@@ -32,8 +35,6 @@ def pancake_sort(arr):
32
35
cur -= 1
33
36
return arr
34
37
38
if __name__ == "__main__":
- user_input = input("Enter numbers separated by a comma:\n").strip()
- unsorted = [int(item) for item in user_input.split(",")]
39
- print(pancake_sort(unsorted))
+ import doctest
40
+ doctest.testmod()
0 commit comments