Touchstone
← Benches

ladder.coding.fix_binary_search

Codinggauntlet

An 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)

ModelHarnessResultTurnstok/sLatencyCtxWhen
gemma-4-26b-a4b-itbarePASS3.2s64k2026-06-23
gemma-4-26b-a4b-itdev_cyclePASS3.2s64k2026-06-23
gemma-4-26b-a4b-itstructured_feedbackPASS164k2026-06-23
gpt-oss-120bbaselinePASS153.03.2s64k2026-06-23
gpt-oss-20bbarePASS164k2026-06-23
gpt-oss-20bdev_cyclePASS164k2026-06-23
gpt-oss-20bstructured_feedbackPASS164k2026-06-23
granite-4.1-8bbaselinePASS122.04.0s128k2026-06-23
llama-3.3-70bbaselinePASS12.845.0s64k2026-06-23
qwen3.5-4bbarePASS1.6m64k2026-06-23
qwen3.5-4bdev_cyclePASS164k2026-06-23
qwen3.5-4bstructured_feedbackPASS164k2026-06-23
qwen3.6-35b-a3bbarePASS32.2s64k2026-06-23
qwen3.6-35b-a3bdev_cyclePASS32.4s64k2026-06-23
qwen3.6-35b-a3bstructured_feedbackPASS164k2026-06-23
devstral-small-2-2512baselinePASS18.69.6s64k2026-06-23
mistral-small-3.1-24b-instruct-2503baselinePASS18.610.3s64k2026-06-23
qwen3.5-122b-a10b-clusterbaselinePASS117.21.6m64k2026-06-29
gpt-oss-20bbaselinePASS177.65.2s64k2026-07-01
qwen3-coder-30bbaselinePASS136.22.5s64k2026-07-01
gemma-4-26b-a4b-itbaselinePASS127.45.0s64k2026-07-01
qwen3.6-35b-a3b-orbaselinePASS1150.213.9s64k2026-07-01
gemini-2.5-flash-litebaselinePASS150.21.8s64k2026-07-01
qwen3.6-35b-bf16baselinePASS134.450.2s64k2026-07-02
qwen3.5-2bbaselinePASS191.61.1s64k2026-07-02
granite-4.1-30bbaselinePASS17.412.3s64k2026-07-02
qwen3.6-27bv1.7.1PASS18.014.2s64k2026-07-02
qwen3-next-80bbaselinePASS144.41.8s64k2026-07-02
qwen3.5-4bbaselinePASS144.01.7m64k2026-07-02
deepseek-r1-distill-qwen-32bbaselinePASS16.52.4m64k2026-07-03
qwen3.6-35b-a3bbaselinePASS153.51.9s64k2026-07-05
qwen3.6-27bbaselinePASS17.714.8s64k2026-07-05
claude-sonnet-4.6baselinePASS147.62.3s195k2026-07-06
qwen3.5-0.8bbaselinefail1174.61.8s64k2026-07-02
phi-4-reasoning-plusbaselinefail113.89.9m64k2026-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