Skip to content

Commit 4862428

Browse files
author
Shreya
committed
Fix doctest formatting
1 parent 9e3cd71 commit 4862428

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

sorts/pancake_sort.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
python pancake_sort.py
99
"""
1010

11-
11+
from __future__ import annotations
1212
def pancake_sort(arr):
1313
"""Sort Array with Pancake Sort.
1414
:param arr: Collection containing comparable items
@@ -20,6 +20,9 @@ def pancake_sort(arr):
2020
[]
2121
>>> pancake_sort([-2, -5, -45])
2222
[-45, -5, -2]
23+
24+
Time Complexity: (O(n^2))
25+
Space Complexity: (O(n))
2326
"""
2427
cur = len(arr)
2528
while cur > 1:
@@ -32,8 +35,6 @@ def pancake_sort(arr):
3235
cur -= 1
3336
return arr
3437

35-
3638
if __name__ == "__main__":
37-
user_input = input("Enter numbers separated by a comma:\n").strip()
38-
unsorted = [int(item) for item in user_input.split(",")]
39-
print(pancake_sort(unsorted))
39+
import doctest
40+
doctest.testmod()

0 commit comments

Comments
 (0)