File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ def cycle_sort(array):
50
50
except NameError :
51
51
raw_input = input # Python 3
52
52
53
- user_input = raw_input ('Enter numbers separated by a comma:\n ' )
54
- unsorted = [int (item ) for item in user_input .split (',' )]
55
- n = len (unsorted )
56
- cycle_sort (unsorted )
57
-
58
- print ("After sort : " )
59
- for i in range (0 , n ):
60
- print (unsorted [i ], end = ' ' )
53
+ user_input = raw_input ('Enter numbers separated by a comma:\n ' )
54
+ unsorted = [int (item ) for item in user_input .split (',' )]
55
+ n = len (unsorted )
56
+ cycle_sort (unsorted )
57
+
58
+ print ("After sort : " )
59
+ for i in range (0 , n ):
60
+ print (unsorted [i ], end = ' ' )
Original file line number Diff line number Diff line change @@ -9,13 +9,11 @@ def wiggle_sort(nums):
9
9
if (i % 2 == 1 ) == (nums [i - 1 ] > nums [i ]):
10
10
nums [i - 1 ], nums [i ] = nums [i ], nums [i - 1 ]
11
11
12
-
13
- print ("Enter the array elements:\n " )
14
- array = list (map (int ,input ().split ()))
15
- print ("The unsorted array is:\n " )
16
- print (array )
17
- wiggle_sort (array )
18
- print ("Array after Wiggle sort:\n " )
19
- print (array )
20
-
21
-
12
+ if __name__ == '__main__' :
13
+ print ("Enter the array elements:\n " )
14
+ array = list (map (int ,input ().split ()))
15
+ print ("The unsorted array is:\n " )
16
+ print (array )
17
+ wiggle_sort (array )
18
+ print ("Array after Wiggle sort:\n " )
19
+ print (array )
You can’t perform that action at this time.
0 commit comments