Build provably correct software using formal methods like Hoare Logic, Weakest Preconditions, and Design-by-Contract.
99
Quality
100%
Does it follow best practices?
Impact
99%
1.45xAverage score across 5 eval scenarios
Your team is developing a high-reliability data processing engine. You need a function that analyzes a sequence of integer sensor readings to identify the longest continuous streak of identical values. For example, in the dataset [1, 2, 2, 2, 3], the longest streak of identical values has a length of 3.
Implement a function max_streak(data) that calculates this length.
Requirements:
Produce a Python file streaks.py containing the max_streak function. The code must be self-verifying and include the formal correctness and termination arguments in the comments.