Your question is Button Combination Detection. 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.
A Starlink user terminal can emit button-press events while an operator performs a diagnostic sequence. Given the event stream and a required button combination, determine whether the combination appears as consecutive presses within a maximum elapsed time.
The combination must match exactly and in order. An unrelated button press breaks the current match, but a valid sequence may overlap with another possible sequence. Return True when any valid occurrence exists, otherwise return False.
Implement detect_combination(events, target, max_duration).
events is a list of (button, timestamp) pairs, ordered by nondecreasing timestamp. button is a string and timestamp is an integer number of milliseconds.target is a non-empty list of button strings describing the required sequence.max_duration is a nonnegative integer in milliseconds.max_duration.def detect_combination(events, target, max_duration):