From 06fcd146bff803a742be7554038029c0ff75d61f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:08:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/cyclic_sort.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sorts/cyclic_sort.py b/sorts/cyclic_sort.py index ac79956e4..afc59b1a2 100644 --- a/sorts/cyclic_sort.py +++ b/sorts/cyclic_sort.py @@ -9,6 +9,7 @@ For manual testing run: python cyclic_sort.py """ + def cyclic_sort(nums: list) -> list: """ Sorts the input list in-place using the Cyclic Sort algorithm. @@ -32,7 +33,7 @@ def cyclic_sort(nums: list) -> list: while i < len(nums): # Calculate the correct index for the current element correct_index = nums[i] - 1 - + # If the current element is not at its correct position, # swap it with the element at its correct index if nums[i] != nums[correct_index]: @@ -44,6 +45,7 @@ def cyclic_sort(nums: list) -> list: return nums + if __name__ == "__main__": import doctest