mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Fix
This commit is contained in:
parent
487fa33f32
commit
331c027fad
|
@ -3,8 +3,6 @@ Bead sort only works for sequences of non-negative integers.
|
|||
https://en.wikipedia.org/wiki/Bead_sort
|
||||
"""
|
||||
|
||||
from itertools import pairwise
|
||||
|
||||
|
||||
def bead_sort(sequence: list) -> list:
|
||||
"""
|
||||
|
@ -33,7 +31,7 @@ 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, (rod_upper, rod_lower) in enumerate(pairwise(sequence)):
|
||||
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): # noqa: RUF007
|
||||
if rod_upper > rod_lower:
|
||||
sequence[i] -= rod_upper - rod_lower
|
||||
sequence[i + 1] += rod_upper - rod_lower
|
||||
|
|
Loading…
Reference in New Issue
Block a user