Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions searches/binary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@
>>> binary_search([0, 5, 7, 10, 15], 6)
-1
"""
if list(sorted_collection) != sorted(sorted_collection):
raise ValueError("sorted_collection must be sorted in ascending order")
if any(
sorted_collection[i] > sorted_collection[i + 1]
for i in range(len(sorted_collection) - 1)
):
raise ValueError("sorted_collection must be sorted in ascending order")

Check failure on line 205 in searches/binary_search.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (invalid-syntax)

searches/binary_search.py:205:5: invalid-syntax: Expected an indented block after `if` statement
left = 0
right = len(sorted_collection) - 1

Expand Down
Loading