Error threshold crossings
Your task
A monitoring pipeline aggregates errors into per-minute counts, giving you a list of integers in time order. An alert fires each time the count crosses the threshold from below: the value is at least threshold now, and the previous minute's value was below it. If the very first minute is already at or above threshold, that counts as a crossing too. Staying at or above threshold does not re-fire. Return how many times the alert fires.
Examples
threshold_crossings(counts: list[int], threshold: int) -> intExample 1
Input
threshold_crossings([0, 2, 5, 7, 3, 6], 5)Output
2