File tree 1 file changed +31
-8
lines changed
1 file changed +31
-8
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ This is a pure Python implementation of the smoothSort algorithm
3
+ Smooth Sort is an algorithm combine the concept of heap sort and the
4
+ concept of merge sort It was designed by Edsger W. Dijkstra
5
+ and later refined by Steven J. Ross.
6
+
7
+ More info on: https://en.wikipedia.org/wiki/Smoothsort
8
+
9
+ For doctests run following command:
10
+ python -m doctest -v smooth_sort.py
11
+ or
12
+ python3 -m doctest -v smooth_sort.py
13
+ For manual testing run:
14
+ python bogo_sort.py
15
+ """
16
+
17
+
1
18
def smooth_sort (unsorted ):
2
19
"""
3
20
Pure implementation of the smooth sort algorithm using Leonardo numbers in Python
@@ -85,11 +102,17 @@ def heapify(start, end):
85
102
86
103
87
104
if __name__ == "__main__" :
88
- user_input = input (
89
- "Enter numbers separated by a comma (or press Enter to exit):\n "
90
- ).strip ()
91
- if not user_input :
92
- print (smooth_sort ([]))
93
- else :
94
- unsorted = [int (item ) for item in user_input .split ("," )]
95
- print (smooth_sort (unsorted ))
105
+ import doctest
106
+
107
+ doctest .testmod ()
108
+ try :
109
+ user_input = input (
110
+ "Enter numbers separated by a comma (or press Enter to exit):\n "
111
+ ).strip ()
112
+ if not user_input :
113
+ print (smooth_sort ([]))
114
+ else :
115
+ unsorted = [int (item ) for item in user_input .split ("," )]
116
+ print (smooth_sort (unsorted ))
117
+ except ValueError :
118
+ print ("Invalid input. Please enter valid integers separated by commas." )
You can’t perform that action at this time.
0 commit comments