adding input option and increasing the number of doctest (#1281)

* adding input option and incresing the number of doctest

* mixing positive and negative numbers in the same test case
This commit is contained in:
mvhb 2019-10-06 15:55:55 -03:00 committed by Christian Clauss
parent 9cc9f67d64
commit 067a9b5136

View File

@ -1,11 +1,14 @@
def stooge_sort(arr):
"""
>>> arr = [2, 4, 5, 3, 1]
>>> stooge_sort(arr)
>>> print(arr)
[1, 2, 3, 4, 5]
Examples:
>>> stooge_sort([18.1, 0, -7.1, -1, 2, 2])
[-7.1, -1, 0, 2, 2, 18.1]
>>> stooge_sort([])
[]
"""
stooge(arr, 0, len(arr) - 1)
return arr
def stooge(arr, i, h):
@ -29,3 +32,8 @@ def stooge(arr, i, h):
# Recursively sort first 2/3 elements
stooge(arr, i, (h - t))
if __name__ == "__main__":
user_input = input("Enter numbers separated by a comma:\n").strip()
unsorted = [int(item) for item in user_input.split(",")]
print(stooge_sort(unsorted))