Substring search
Your task
Implement substring search by hand. Given a text and a pattern, return the index of the first occurrence of the pattern in the text, or -1 if it never occurs. An empty pattern matches at index 0. Use a direct character-by-character scan, no regex and no built-in search helpers. For example, the pattern 'sad' first occurs in 'sadbutsad' at index 0.
Examples
index_of(text: str, pattern: str) -> intExample 1
Input
index_of("sadbutsad", "sad")Output
0