Skip to content

Commit 2d6618d

Browse files
Combine conditional branches to satisfy ruff linting
- Updated `wiggle_sort` logic to merge the odd and even swap conditions using a single `or` expression. - Fixes SIM114 ruff linter check failure (`Combine if branches using logical or operator`).
1 parent 2101118 commit 2d6618d

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎sorts/wiggle_sort.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def wiggle_sort(nums: list) -> list:
2525
[-45.11, -2.1, -5.68]
2626
"""
2727
for i in range(1, len(nums)):
28-
if i % 2 == 1 and nums[i - 1] > nums[i]:
29-
nums[i - 1], nums[i] = nums[i], nums[i - 1]
30-
elif i % 2 == 0 and nums[i - 1] < nums[i]:
28+
if (i % 2 == 1 and nums[i - 1] > nums[i]) or (i % 2 == 0 and nums[i - 1] < nums[i]):
3129
nums[i - 1], nums[i] = nums[i], nums[i - 1]
3230

3331
return nums

0 commit comments

Comments
 (0)