Skip to content
mager-bench1.3
← historical challenges

binary-search

Binary search implementation with full docs

the prompt

$ cat binary-search.prompt
Implement `binary_search(arr: list[int], target: int) -> int` in Python. It should return the index of target in a sorted list, or -1 if not found. Write a proper docstring with Args, Returns, and Raises sections. Add inline comments explaining the algorithm logic. Include 3 test cases as examples in the docstring.

rubric

correctness

Is the binary search algorithm correct? Does it handle edge cases (empty list, target not found, duplicates)?

quality

Is the loop/recursion clean? Correct handling of integer overflow for mid calculation?

documentation

Does it have Args/Returns/Raises docstring? Are inline comments meaningful (not just restating the code)? Are the 3 examples correct?

results

GPT-6 Astra

10.0
correctness 10.0quality 10.0documentation 10.016289ms

# The implementation is correct for empty lists, missing targets, and duplicates, uses clean inclusive bounds and overflow-safe midpoint calculation, and provides a complete docstring with three accurate examples and meaningful comments.

inspect full trace →

GPT-5.6 Sol

9.3
correctness 10.0quality 8.0documentation 10.011595ms

# The implementation is correct and exceptionally well documented, though full type and sortedness validation makes the overall runtime O(n), undermining binary search's usual O(log n) performance.

inspect full trace →