anthropic/claude-sonnet-4.6 🖼️📝🔢 → 📝
Performance
13.9sTypical run time
66 tok/sThroughput
86.5KTotal runs
About
Claude Sonnet 4.6 from Anthropic: a full upgrade to coding, computer use, long-context reasoning, agent planning, knowledge work, and design, with a 1 million token context window in beta.
Example Output
Prompt:
"Write a Python function merge_intervals(intervals) that takes a list of [start, end] integer intervals and returns the list of merged, non-overlapping intervals in sorted order. Include a short docstring with a usage example, and use only the standard library."
Output
def merge_intervals(intervals):
"""
Merge all overlapping intervals and return a sorted list of non-overlapping intervals.
Args:
intervals (list[list[int]]): A list of [start, end] integer intervals.
Returns:
list[list[int]]: Merged, non-overlapping intervals in ascending order.
Example:
>>> merge_intervals([[1, 3], [2, 6], [8, 10], [15, 18]])
[[1, 6], [8, 10], [15, 18]]
>>> merge_intervals([[1, 4], [4, 5]])
[[1, 5]]
>>> merge_intervals([])
[]
"""
if not intervals:
return []
# Sort intervals by their start value
sorted_intervals = sorted(intervals, key=lambda x: x[0])
merged = [sorted_intervals[0][:]] # Copy first interval to avoid mutating input
for current_start, current_end in sorted_intervals[1:]:
last_merged = merged[-1]
# Intervals overlap or are contiguous if current start <= last merged end
if current_start <= last_merged[1]:
# Extend the last merged interval if necessary
last_merged[1] = max(last_merged[1], current_end)
else:
# No overlap: start a new interval
merged.append([current_start, current_end])
return merged
# ---------------------------------------------------------------------------
# Quick self-test
# ---------------------------------------------------------------------------
if __name__ == "__main__":
test_cases = [
# (input, expected_output)
([[1, 3], [2, 6], [8, 10], [15, 18]], [[1, 6], [8, 10], [15, 18]]),
([[1, 4], [4, 5]], [[1, 5]]),
([[1, 4], [0, 4]], [[0, 4]]),
([[1, 4], [2, 3]], [[1, 4]]), # One interval fully inside another
([[5, 10], [1, 3]], [[1, 3], [5, 10]]), # Unsorted input
([[1, 4]], [[1, 4]]), # Single interval
([], []), # Empty input
]
all_passed = True
for intervals, expected in test_cases:
result = merge_intervals(intervals)
status = "PASS" if result == expected else "FAIL"
if status == "FAIL":
all_passed = False
print(f"[{status}] merge_intervals({intervals})")
if status == "FAIL":
print(f" Expected : {expected}")
print(f" Got : {result}")
print("
All tests passed!" if all_passed else "
Some tests FAILED.")
How it works
| Step | Description |
|---|---|
| Guard clause | Return [] immediately for empty input. |
| Sort | Sort intervals by start value so we only need a single left-to-right pass. |
| Iterate | Keep a running merged list. For each interval, compare its start with the end of the last merged interval. |
| Overlap check | current_start <= last_merged[1] — if true, extend the last interval's end to max(last_end, current_end). |
| No overlap | Otherwise, append the interval as a new, separate entry. |
Time complexity: O(n log n) — dominated by sorting.
Space complexity: O(n) for the output list.
Performance Metrics
13.90s
Prediction Time
13.92s
Total Time
All Input Parameters
{
"prompt": "Write a Python function `merge_intervals(intervals)` that takes a list of [start, end] integer intervals and returns the list of merged, non-overlapping intervals in sorted order. Include a short docstring with a usage example, and use only the standard library.",
"max_tokens": 8192,
"system_prompt": "You are an experienced Python engineer",
"max_image_resolution": 0.5
}
Input Parameters
- image
- Optional input image. Images are priced as (width px * height px)/750 input tokens
- prompt (required)
- Input prompt
- max_tokens
- Maximum number of output tokens
- system_prompt
- System prompt
- max_image_resolution
- Maximum image resolution in megapixels. Scales down image before sending it to Claude, to save time and money.
Output Schema
Output
Example Execution Logs
Running prediction... Using model: claude-sonnet-4-6
Version Details
- Version ID
01cef263f8154ca57bcf5750ae6e966cb8cb225a47b6a52e4ba8af7b3e01dc40- Version Created
- May 26, 2026