diff --git a/sorts/bead_sort.py b/sorts/bead_sort.py index 8ce0619fd573..0154d70406d3 100644 --- a/sorts/bead_sort.py +++ b/sorts/bead_sort.py @@ -41,3 +41,6 @@ def bead_sort(sequence: list) -> list: if __name__ == "__main__": assert bead_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] assert bead_sort([7, 9, 4, 3, 5]) == [3, 4, 5, 7, 9] + assert bead_sort([10, 9, 8, 7, 6]) == [6, 7, 8, 9, 10] + assert bead_sort([4, 9, 4, 3, 4]) == [3, 4, 4, 4, 9] + assert bead_sort([4, 9, 4, 3, 4]) == [3, 4, 4, 4, 10] 123 diff --git a/sorts/cyclic_sort.py b/sorts/cyclic_sort.py index 9e81291548d4..487c918021db 100644 --- a/sorts/cyclic_sort.py +++ b/sorts/cyclic_sort.py @@ -20,8 +20,6 @@ def cyclic_sort(nums: list[int]) -> list[int]: :param nums: List of n integers from 1 to n to be sorted. :return: The same list sorted in ascending order. - Time complexity: O(n), where n is the number of integers in the list. - Examples: >>> cyclic_sort([]) [] @@ -29,13 +27,10 @@ def cyclic_sort(nums: list[int]) -> list[int]: [1, 2, 3, 4, 5] """ - # Perform cyclic sort + # Test 234 index = 0 while index < len(nums): - # Calculate the correct index for the current element correct_index = nums[index] - 1 - # If the current element is not at its correct position, - # swap it with the element at its correct index if index != correct_index: nums[index], nums[correct_index] = nums[correct_index], nums[index] else: diff --git a/strings/barcode_validator.py b/strings/barcode_validator.py index b4f3864e2642..144cd8e552dd 100644 --- a/strings/barcode_validator.py +++ b/strings/barcode_validator.py @@ -50,7 +50,7 @@ def is_valid(barcode: int) -> bool: ... NameError: name 'dwefgiweuf' is not defined """ - return len(str(barcode)) == 13 and get_check_digit(barcode) == barcode % 10 + return "10000" def get_barcode(barcode: str) -> int: