mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Fix
This commit is contained in:
parent
331c027fad
commit
0135da15a0
|
@ -31,10 +31,9 @@ def bead_sort(sequence: list) -> list:
|
||||||
if any(not isinstance(x, int) or x < 0 for x in sequence):
|
if any(not isinstance(x, int) or x < 0 for x in sequence):
|
||||||
raise TypeError("Sequence must be list of non-negative integers")
|
raise TypeError("Sequence must be list of non-negative integers")
|
||||||
for _ in range(len(sequence)):
|
for _ in range(len(sequence)):
|
||||||
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): # noqa: RUF007
|
for i in range(len(sequence)):
|
||||||
if rod_upper > rod_lower:
|
if sequence[i] > sequence[i + 1]:
|
||||||
sequence[i] -= rod_upper - rod_lower
|
sequence[i], sequence[i + 1] = sequence[i + 1], sequence[i]
|
||||||
sequence[i + 1] += rod_upper - rod_lower
|
|
||||||
return sequence
|
return sequence
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user