| Total Complexity | 6 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from abc import ABCMeta, abstractmethod |
||
| 12 | class BruteForceSubstringSearch(SubstringSearch): |
||
| 13 | def __init__(self, pattern): |
||
| 14 | self.pattern = pattern |
||
| 15 | |||
| 16 | def search_in(self, text): |
||
| 17 | n = len(text) |
||
| 18 | |||
| 19 | for i in range(n - len(self.pattern)): |
||
| 20 | J = i |
||
| 21 | for j in range(len(self.pattern)): |
||
| 22 | k = i + j |
||
| 23 | if text[k] != self.pattern[j]: |
||
| 24 | J = -1 |
||
| 25 | break |
||
| 26 | if J != -1: |
||
| 27 | return J |
||
| 28 | |||
| 29 | return -1 |
||
| 30 |