code
Feb 17, 2026CODE-006Write comprehensive unit tests for this function. Cover all edge cases, including boundary conditions, error cases, and typical usage. ```python def merge_sorted_streams(*streams, max_items=None): """ Merge multiple sorted iterables into a single sorted output. Args: *streams: Variable number of sorted iterables max_items: Optional limit on total items to yield Yields: Items from all streams in sorted order Raises: ValueError: If any stream is not sorted """ import heapq heap = [] iterators = [iter(s) for s in streams] # Initialize heap with first item from each stream for i, it in enumerate(iterators): try: item = next(it) heapq.heappush(heap, (item, i)) except StopIteration: pass count = 0 prev = None while heap and (max_items is None or count < max_items): item, stream_idx = heapq.heappop(heap) # Validate sorting if prev is not None and item < prev: raise ValueError(f"Stream {stream_idx} is not sorted") yield item prev = item count += 1 # Get next item from same stream try: next_item = next(iterators[stream_idx]) heapq.heappush(heap, (next_item, stream_idx)) except StopIteration: pass ``` Use pytest. Include parametrized tests where appropriate.
Winner
Grok Code Fast
xAI
9.12
WINNER SCORE
matrix avg: 6.84
10×10 Judgment Matrix · 100 judgments
OPEN DATA
| Judge ↓ / Respondent → | Grok Code Fast | Gemini 3 | GLM-4-7 | Claude Opus 4.5 | Gemini 3 | Claude Sonnet 4.5 | MiniMax M2 | DeepSeek V3.2 | GPT-5.2-Codex | Grok 3 (Direct) |
|---|---|---|---|---|---|---|---|---|---|---|
| Grok Code Fast | — | 2.9 | 2.0 | 8.7 | 9.8 | 8.6 | 7.8 | 9.8 | 5.5 | 9.1 |
| Gemini 3 | 0.0 | — | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.5 | 0.0 |
| GLM-4-7 | 9.3 | 1.0 | — | 6.3 | 0.0 | 6.8 | 0.0 | 0.0 | 2.5 | 8.8 |
| Claude Opus 4.5 | 8.0 | 1.7 | 0.7 | — | 8.6 | 7.5 | 7.7 | 7.1 | 0.0 | 7.4 |
| Gemini 3 | 9.8 | 2.5 | 9.8 | 9.3 | — | 8.4 | 8.6 | 7.6 | 3.3 | 9.8 |
| Claude Sonnet 4.5 | 8.8 | 1.6 | 3.5 | 8.3 | 9.0 | — | 4.5 | 8.0 | 2.6 | 7.8 |
| MiniMax M2 | 9.0 | 1.0 | 8.8 | 5.5 | 0.0 | 5.7 | — | 6.2 | 3.6 | 8.6 |
| DeepSeek V3.2 | 9.6 | 5.8 | 9.3 | 9.2 | 9.6 | 8.3 | 9.4 | — | 7.7 | 8.6 |
| GPT-5.2-Codex | 0.0 | 1.0 | 0.0 | 4.5 | 8.8 | 5.8 | 3.0 | 3.8 | — | 7.8 |
| Grok 3 (Direct) | 9.3 | 4.5 | 8.6 | 8.6 | 8.6 | 8.6 | 8.6 | 8.6 | 4.5 | — |