From 0135da15a07f425838019c6deceb54980f26d472 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Tue, 2 Apr 2024 22:47:01 +0300 Subject: [PATCH] Fix --- sorts/bead_sort.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sorts/bead_sort.py b/sorts/bead_sort.py index 8ce0619fd..d00a4ad64 100644 --- a/sorts/bead_sort.py +++ b/sorts/bead_sort.py @@ -31,10 +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, (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 + for i in range(len(sequence)): + if sequence[i] > sequence[i + 1]: + sequence[i], sequence[i + 1] = sequence[i + 1], sequence[i] return sequence