You have now built a naive pattern search, congratulations!
The algorithm begins by iterating through the
text and setting a variable
match_count equal to
Then, for each index of the
text, the algorithm iterates through the
pattern to check for matching characters, and if found, increments
match_count. Otherwise, the search breaks the
pattern iteration and moves onto the next index in
Each time the
pattern iteration is completed, the
match_count is compared to the length of the
pattern to determine if a match is found.
Now there is only one thing left to do, test the algorithm on more inputs!
Some additional texts and patterns have been added to the code. Invoke
pattern4. Observe your amazing algorithm handle everything thrown at it!