Round #229

07 May 2026, 15:34· csharp· meta/llama-3.3-70b-instruct· r12-real-contracts
Complexity
band 0
ZP / UO / OBS
0 / 0 / 0
Journey weight
0
Lightshift ΔL

Prompt

Implement a sliding window aggregation over a time-ordered sequence

Zero-point index (what the engine surfaced)

ZPI-ZPI-0022 | 2026-05-07T15:34:20Z Implement a sliding window aggregation over a time-ordered sequence ZERO POINT — 0 entries (structural invariants) UNOBSERVED — 0 entries (implied truths) OBSERVED — 0 entries (explicit in request) COMPLEXITY │ 0 entries │ spread: 0° │ band: LOW

Baseline response (no ZPI)

**Sliding Window Aggregation Implementation in C#** Below is a C# implementation of a sliding window aggregation over a time-ordered sequence. This example uses a simple moving average aggregation, but you can easily modify it to use other aggregation functions (e.g., sum, max, min). ### SlidingWindowAggregator Class ```csharp using System; using System.Collections.Generic; using System.Linq; public class SlidingWindowAggregator { private readonly int _windowSize; private readonly Func<IEnumerable<double>, double> _aggregationFunction; public SlidingWindowAggregator(int windowSize, Func<IEnumerable<double>, double> aggregationFunction) { _windowSize = windowSize; _aggregationFunction = aggregationFunction; } public IEnumerable<double> Aggregate(IEnumerable<(DateTime, double)> sequence) { var queue = new Queue<(DateTime, double)>(); foreach (var (timestamp, value) in sequence) { queue.Enqueue((timestamp, value)); while (queue.Count > _windowSize) { queue.Dequeue(); } if (queue.Count == _windowSize) { var values = queue.Select(x => x.Item2); yield return _aggregationFunction(values); } } } } ``` ### Example Usage ```csharp class Program { static void Main() { // Define a sample time-ordered sequence var sequence = new[] { (new DateTime(2022, 1, 1, 0, 0, 0), 10.0), (new DateTime(2022, 1, 1, 0, 1, 0), 20.0), (new DateTime(2022, 1, 1, 0, 2, 0), 30.0), (new DateTime(2022, 1, 1, 0, 3, 0), 40.0), (new DateTime(2022, 1, 1, 0, 4, 0), 50.0), (new DateTime(2022, 1, 1, 0, 5, 0), 60.0), }; // Create a sliding window aggregator with a window size of 3 and a moving average aggregation function var aggregator = new SlidingWindowAggregator(3, values => values.Average()); // Apply the sliding window aggregation to the sequence var aggregatedValues = aggregator.Aggregate(sequence); // Print the aggregated values foreach (var value in aggregatedValues) { Console.WriteLine(value); } } } ``` ### Output ``` 20.0 30.0 40.0 50.0 ``` In this example, the sliding window aggregator applies a moving average aggregation function to a time-ordered sequence of values. The `SlidingWindowAggregator` class takes a window size and an aggregation function as constructor parameters. The `Aggregate` method applies the aggregation function to the values within the sliding window and yields the aggregated values. You can modify the aggregation function to use other aggregation methods, such as sum, max, or min, by passing a different function to the `SlidingWindowAggregator` constructor. For example, to use a sum aggregation function, you can pass `values => values.Sum()` as the aggregation function.

Enhanced response (with ZPI)

```csharp using System; using System.Collections.Generic; using System.Linq; public class SlidingWindowAggregator { private readonly int _windowSize; private readonly Func<IEnumerable<double>, double> _aggregationFunction; public SlidingWindowAggregator(int windowSize, Func<IEnumerable<double>, double> aggregationFunction) { if (windowSize <= 0) { throw new ArgumentException("Window size must be a positive integer", nameof(windowSize)); } _windowSize = windowSize; _aggregationFunction = aggregationFunction ?? throw new ArgumentNullException(nameof(aggregationFunction)); } public IEnumerable<double> Aggregate(IEnumerable<double> sequence) { var window = new Queue<double>(); foreach (var value in sequence) { window.Enqueue(value); if (window.Count > _windowSize) { window.Dequeue(); } if (window.Count == _windowSize) { yield return _aggregationFunction(window); } } } } class Program { static void Main() { var sequence = Enumerable.Range(1, 10).Select(i => (double)i); var aggregator = new SlidingWindowAggregator(3, values => values.Average()); var aggregatedValues = aggregator.Aggregate(sequence); foreach (var value in aggregatedValues) { Console.WriteLine(value); } } } ``` This implementation defines a `SlidingWindowAggregator` class that takes a window size and an aggregation function in its constructor. The `Aggregate` method applies the aggregation function to each window of the specified size in the input sequence, yielding the aggregated values. In the example usage, a sequence of numbers from 1 to 10 is created, and a sliding window aggregator with a window size of 3 and an average aggregation function is instantiated. The aggregated values are then printed to the console. The `SlidingWindowAggregator` class uses a queue to efficiently manage the sliding window, ensuring that the window size remains constant and that the aggregation function is applied to the correct values. The `Aggregate` method is designed to work with any aggregation function, making it a flexible and reusable solution for various use cases.

Grader chain

Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.

V1claude-haiku-4-5-20251001
Better
V4qwen2.5-coder-7b-instruct
Better

Comments

Our grader said what it said. What do you say? Comment as a guest below.

No comments yet. Be the first to say what you make of this round.

← back to all rounds