Your question is RC Error-Rate Loop Logic. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Explain how you would implement the missing checkRC logic for the following pattern: you repeatedly call doSomething() returning rc (0 good, 1 error), and you exit if errors exceed MAX_ERROR within TIME seconds.
Implement check_rc(events, max_error, time_seconds). events contains [timestamp, rc] pairs sorted by nondecreasing timestamp. Return the zero-based index of the first event that causes more than max_error errors in the inclusive interval [timestamp - time_seconds, timestamp]; return -1 if the threshold is never exceeded. Assume each rc is either 0 or 1.
def check_rc(events, max_error, time_seconds):