← Benches
ladder.coding.fix_binary_search
CodinggauntletAn owned ladder bench, graded mechanically against a fixed test.
Solved
33/35
runs passed
Models
22
have attempted
Harnesses
5
scaffolds tried
Runs (latest per model × harness — solved sorted first)
| Model | Harness | Result | Turns | tok/s | Latency | Ctx | When |
|---|---|---|---|---|---|---|---|
| gemma-4-26b-a4b-it | bare | PASS | — | — | 3.2s | 64k | 2026-06-23 |
| gemma-4-26b-a4b-it | dev_cycle | PASS | — | — | 3.2s | 64k | 2026-06-23 |
| gemma-4-26b-a4b-it | structured_feedback | PASS | 1 | — | — | 64k | 2026-06-23 |
| gpt-oss-120b | baseline | PASS | 1 | 53.0 | 3.2s | 64k | 2026-06-23 |
| gpt-oss-20b | bare | PASS | 1 | — | — | 64k | 2026-06-23 |
| gpt-oss-20b | dev_cycle | PASS | 1 | — | — | 64k | 2026-06-23 |
| gpt-oss-20b | structured_feedback | PASS | 1 | — | — | 64k | 2026-06-23 |
| granite-4.1-8b | baseline | PASS | 1 | 22.0 | 4.0s | 128k | 2026-06-23 |
| llama-3.3-70b | baseline | PASS | 1 | 2.8 | 45.0s | 64k | 2026-06-23 |
| qwen3.5-4b | bare | PASS | — | — | 1.6m | 64k | 2026-06-23 |
| qwen3.5-4b | dev_cycle | PASS | 1 | — | — | 64k | 2026-06-23 |
| qwen3.5-4b | structured_feedback | PASS | 1 | — | — | 64k | 2026-06-23 |
| qwen3.6-35b-a3b | bare | PASS | — | — | 32.2s | 64k | 2026-06-23 |
| qwen3.6-35b-a3b | dev_cycle | PASS | — | — | 32.4s | 64k | 2026-06-23 |
| qwen3.6-35b-a3b | structured_feedback | PASS | 1 | — | — | 64k | 2026-06-23 |
| devstral-small-2-2512 | baseline | PASS | 1 | 8.6 | 9.6s | 64k | 2026-06-23 |
| mistral-small-3.1-24b-instruct-2503 | baseline | PASS | 1 | 8.6 | 10.3s | 64k | 2026-06-23 |
| qwen3.5-122b-a10b-cluster | baseline | PASS | 1 | 17.2 | 1.6m | 64k | 2026-06-29 |
| gpt-oss-20b | baseline | PASS | 1 | 77.6 | 5.2s | 64k | 2026-07-01 |
| qwen3-coder-30b | baseline | PASS | 1 | 36.2 | 2.5s | 64k | 2026-07-01 |
| gemma-4-26b-a4b-it | baseline | PASS | 1 | 27.4 | 5.0s | 64k | 2026-07-01 |
| qwen3.6-35b-a3b-or | baseline | PASS | 1 | 150.2 | 13.9s | 64k | 2026-07-01 |
| gemini-2.5-flash-lite | baseline | PASS | 1 | 50.2 | 1.8s | 64k | 2026-07-01 |
| qwen3.6-35b-bf16 | baseline | PASS | 1 | 34.4 | 50.2s | 64k | 2026-07-02 |
| qwen3.5-2b | baseline | PASS | 1 | 91.6 | 1.1s | 64k | 2026-07-02 |
| granite-4.1-30b | baseline | PASS | 1 | 7.4 | 12.3s | 64k | 2026-07-02 |
| qwen3.6-27b | v1.7.1 | PASS | 1 | 8.0 | 14.2s | 64k | 2026-07-02 |
| qwen3-next-80b | baseline | PASS | 1 | 44.4 | 1.8s | 64k | 2026-07-02 |
| qwen3.5-4b | baseline | PASS | 1 | 44.0 | 1.7m | 64k | 2026-07-02 |
| deepseek-r1-distill-qwen-32b | baseline | PASS | 1 | 6.5 | 2.4m | 64k | 2026-07-03 |
| qwen3.6-35b-a3b | baseline | PASS | 1 | 53.5 | 1.9s | 64k | 2026-07-05 |
| qwen3.6-27b | baseline | PASS | 1 | 7.7 | 14.8s | 64k | 2026-07-05 |
| claude-sonnet-4.6 | baseline | PASS | 1 | 47.6 | 2.3s | 195k | 2026-07-06 |
| qwen3.5-0.8b | baseline | fail | 1 | 174.6 | 1.8s | 64k | 2026-07-02 |
| phi-4-reasoning-plus | baseline | fail | 1 | 13.8 | 9.9m | 64k | 2026-07-02 |
Transcripts
gemma-4-26b-a4b-it · bare · PASS
```python
def binary_search(arr, target):
"""
Performs a binary search on a sorted ascending list to find the index of target.
Returns the index if found, otherwise returns -1.
"""
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1
```gemma-4-26b-a4b-it · dev_cycle · PASS
```python
def binary_search(arr, target):
"""
Performs a binary search on a sorted ascending list to find the index of target.
Returns the index if found, otherwise returns -1.
"""
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1
```gpt-oss-120b · baseline · PASS
```python
def binary_search(arr, target):
"""
Perform a binary search on a sorted ascending list `arr` and return the index of `target`.
Returns -1 if `target` is not present.
"""
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # move past the middle element
else:
hi = mid
return -1
```granite-4.1-8b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1
```llama-3.3-70b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # Fix: changed from lo = mid to lo = mid + 1
else:
hi = mid # Fix: changed from hi = mid to hi = mid, but should be hi = mid - 1 for correctness in all cases
return -1
```qwen3.5-4b · bare · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3.6-35b-a3b · bare · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3.6-35b-a3b · dev_cycle · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```devstral-small-2-2512 · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```mistral-small-3.1-24b-instruct-2503 · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1
```qwen3.5-122b-a10b-cluster · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```gpt-oss-20b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3-coder-30b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # Fixed: should be mid + 1
else:
hi = mid
return -1
```gemma-4-26b-a4b-it · baseline · PASS
```python
def binary_search(arr, target):
"""
Performs a binary search on a sorted list to find the index of target.
Returns the index if found, otherwise returns -1.
"""
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1
```qwen3.6-35b-a3b-or · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```gemini-2.5-flash-lite · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3.6-35b-bf16 · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3.5-2b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: Move to the right half, not left
else:
hi = mid
return -1
```granite-4.1-30b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # fix: move past the current mid
else:
hi = mid
return -1
```qwen3.6-27b · v1.7.1 · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: was `mid`, should be `mid + 1` to avoid infinite loop and correctly narrow search space
else:
hi = mid
return -1
```qwen3-next-80b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```qwen3.5-4b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
```deepseek-r1-distill-qwen-32b · baseline · PASS
To fix this binary search function, we need to adjust how the lower bound (`lo`) is updated when the middle element is less than the target. The original code incorrectly set `lo` to `mid`, which could cause infinite loops or incorrect results. By setting `lo` to `mid + 1` in such cases, we ensure that the search correctly moves past the current midpoint.
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # Fixed the bug by adding 1
else:
hi = mid
return -1
```qwen3.6-35b-a3b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: was lo = mid, which could cause infinite loop
else:
hi = mid
return -1
```qwen3.6-27b · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: was `mid`, should be `mid + 1` to avoid infinite loop and correctly narrow search space
else:
hi = mid
return -1
```claude-sonnet-4.6 · baseline · PASS
```python
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: was `mid`, causing infinite loop
else:
hi = mid
return -1
```qwen3.5-0.8b · baseline · fail
```python
from solution import binary_search
def binary_search(arr, target):
"""
Returns the index of `target` in a sorted ascending list.
If not found, returns -1.
Args:
arr (list): A sorted list of integers.
target (int): The value to search for.
Returns:
int: Index of `target`, or -1 if not found.
"""
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid + 1 # FIX: Changed to mid + 1 instead of mid
else:
hi = mid
return -1
# Example usage:
if __name__ == "__main__":
test_cases = [
(range(5), 3),
(range(5), 4),
(range(5), 6),
(range(0, 5), 2),
(range(0, 5), 1),
(range(0, 5), 5),
]
for arr, target in test_cases:
result = binary_search(arr, target)
print(f"binary_search({arr}, {target}) -> {result}")
```phi-4-reasoning-plus · baseline · fail
We are asked: "The function below is meant to return the index of `target` in a sorted ascending list, or -1 if absent, but it has a bug. Find and fix it, and return the corrected full function (importable as `from solution import binary_search`)."
Given code:
```
def binary_search(arr, target):
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
lo = mid # BUG
else:
hi = mid
return -1
```
Bug: The bug is in the update of `lo` and `hi`. In binary search, when we set new boundaries, we must do something like:
- if arr[mid] < target then we want to search right half. So we should set lo = mid + 1.
- else (arr[mid] > target) then hi = mid.
But the code uses "lo = mid" and "hi = mid", which might cause infinite loop or incorrect boundaries. But wait, check: The original code sets hi = len(arr). And while condition is while lo < hi. So it's using half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same mid might be rechecked repeatedly.
Wait, but careful: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element might be rechecked repeatedly.
Wait, but check: The code uses "while lo < hi:" and sets hi = len(arr) initially. That means it's using a half-open interval [lo, hi). In that case, if arr[mid] < target then we want to set lo = mid + 1 because otherwise the same element