diff --git a/sorts/bead_sort.py b/sorts/bead_sort.py index 51133f7a2..8ce0619fd 100644 --- a/sorts/bead_sort.py +++ b/sorts/bead_sort.py @@ -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