Skip to content

Commit

Permalink
Update sorts/bead_sort.py
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
MaximSmolskiy and cclauss authored Apr 8, 2024
1 parent bc2225d commit 2c1816b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sorts/bead_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def bead_sort(sequence: list) -> list:
if any(not isinstance(x, int) or x < 0 for x in sequence):
raise TypeError("Sequence must be list of non-negative integers")
for _ in range(len(sequence)):
for i in range(len(sequence) - 1):
if sequence[i] > sequence[i + 1]:
sequence[i], sequence[i + 1] = sequence[i + 1], sequence[i]
for i, (rod_upper, rod_lower) in enumerate(pairwise(sequence)):
if rod_upper > rod_lower:
sequence[i], sequence[i + 1] = rod_lower, rod_upper
return sequence


Expand Down

0 comments on commit 2c1816b

Please sign in to comment.