Your question is Stream Pattern Detection Function. 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.
Nuna's healthcare data pipelines process event tokens as a stream. Given an iterable of string tokens and a non-empty pattern, return the zero-based starting index of every occurrence of the pattern in the stream, including overlapping matches.
Your function must process the stream in one pass and must not convert the entire iterable to a list. This requirement matters because the stream may be much larger than available memory.
Implement find_pattern(events, pattern).
events is an iterable of strings. It may be a list, generator, or other single-pass iterator.pattern is a non-empty list of strings.pattern begins in events.def find_pattern(events, pattern):