Skip to content

Commit e735102

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 720caf7 commit e735102

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

data_structures/reversesort.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def reverse_selection_sort(arr: list[int]) -> list[int]:
22
"""
3-
Sorts an array using a modified selection sort algorithm where after finding
3+
Sorts an array using a modified selection sort algorithm where after finding
44
the minimum element, a subarray is reversed instead of swapping.
55
66
Parameters:
@@ -12,16 +12,16 @@ def reverse_selection_sort(arr: list[int]) -> list[int]:
1212
Example:
1313
>>> reverse_selection_sort([64, 25, 12, 22, 11])
1414
[11, 12, 22, 25, 64]
15-
15+
1616
>>> reverse_selection_sort([5, 4, 3, 2, 1])
1717
[1, 2, 3, 4, 5]
18-
18+
1919
>>> reverse_selection_sort([3, 1, 2])
2020
[1, 2, 3]
21-
21+
2222
>>> reverse_selection_sort([10])
2323
[10]
24-
24+
2525
>>> reverse_selection_sort([])
2626
[]
2727
"""
@@ -39,10 +39,12 @@ def reverse_selection_sort(arr: list[int]) -> list[int]:
3939
# If the minimum is not already at position i, reverse the subarray
4040
if min_index != i:
4141
# Reverse the subarray from position i to min_index
42-
arr[i:min_index + 1] = reversed(arr[i:min_index + 1])
42+
arr[i : min_index + 1] = reversed(arr[i : min_index + 1])
4343

4444
return arr
4545

46+
4647
if __name__ == "__main__":
4748
import doctest
49+
4850
doctest.testmod()

0 commit comments

Comments
 (0)