Sustained faults across spans
Your task
A motor controller reports a fault word once per tick, bit f standing for fault f, and faults are numbered 0 to 29. The console only trusts a fault it has watched hold, so it calls a fault sustained over a stretch of ticks when that fault is active in every single tick of the stretch. frames holds the words in tick order and span gives how many consecutive ticks a stretch covers, always at least one. Return one word per stretch, in the order the stretches begin, holding exactly the faults sustained across that stretch. frames can run to a hundred thousand words and span can be almost as long, so rebuilding a stretch from scratch is too slow. Return an empty list when span is longer than the run of frames.
Examples
sustained_fault_masks(frames: list[int], span: int) -> list[int]Example 1
Input
sustained_fault_masks([7, 6, 14], 2)Output
[6, 6]Example 2
Input
sustained_fault_masks([1, 2, 4], 1)Output
[1, 2, 4]Example 3
Input
sustained_fault_masks([5, 5, 5, 1], 3)Output
[5, 1]