Assignment

Implement the Boyer-Moore-Horspool algorithm. Write a Python function firstOccurrence that takes as parameters a text T and a pattern P; as an optional parameter alphabet a string with the characters of the alphabet used can be given (its default value is “ATCG”). The function returns the index of the first occurrence of the pattern P in the text T, -1 if P does not occur in T.

Examples

>>> firstOccurrence("ATTATTAAA", "AAA")
6
>>> firstOccurrence("AATTATTATCGATTACGGA", "AAA")
-1