Skip to content

Commit 0135da1

Browse files
committed
Fix
1 parent 331c027 commit 0135da1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: sorts/bead_sort.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ def bead_sort(sequence: list) -> list:
3131
if any(not isinstance(x, int) or x < 0 for x in sequence):
3232
raise TypeError("Sequence must be list of non-negative integers")
3333
for _ in range(len(sequence)):
34-
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): # noqa: RUF007
35-
if rod_upper > rod_lower:
36-
sequence[i] -= rod_upper - rod_lower
37-
sequence[i + 1] += rod_upper - rod_lower
34+
for i in range(len(sequence)):
35+
if sequence[i] > sequence[i + 1]:
36+
sequence[i], sequence[i + 1] = sequence[i + 1], sequence[i]
3837
return sequence
3938

4039

0 commit comments

Comments
 (0)