

"""simple docstring"""



class 					a						:



    """simple docstring"""



    def __init__(     self: Any       ):






         """simple docstring"""


         A__										=  """"""
         A__										=  """"""
         A__										=  []

    def 				UpperCamelCase	(     self: Optional[Any]    ,						UpperCamelCase: List[Any]    ,						UpperCamelCase: Any       ):






         """simple docstring"""


         if m == -1:
              return n + 1
         elif n == -1:
              return m + 1
         elif self.dp[m][n] > -1:
              return self.dp[m][n]
         else:
              if self.worda[m] == self.worda[n]:
                   A__										=  self.__min_dist_top_down_dp(m - 1    ,						n - 1       )
              else:
                   A__										=  self.__min_dist_top_down_dp(_SCREAMING_SNAKE_CASE    ,						n - 1       )
                   A__										=  self.__min_dist_top_down_dp(m - 1    ,						_SCREAMING_SNAKE_CASE       )
                   A__										=  self.__min_dist_top_down_dp(m - 1    ,						n - 1       )
                   A__										=  1 + min(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE       )

              return self.dp[m][n]

    def 				UpperCamelCase	(     self: Tuple    ,						UpperCamelCase: Tuple    ,						UpperCamelCase: str       ):






         """simple docstring"""


         A__										=  worda
         A__										=  worda
         A__										=  [[-1 for _ in range(len(_SCREAMING_SNAKE_CASE       )       )] for _ in range(len(_SCREAMING_SNAKE_CASE       )       )]

         return self.__min_dist_top_down_dp(len(_SCREAMING_SNAKE_CASE       ) - 1    ,						len(_SCREAMING_SNAKE_CASE       ) - 1       )





    def 				UpperCamelCase	(     self: List[str]    ,						UpperCamelCase: int    ,						UpperCamelCase: Optional[Any]       ):






         """simple docstring"""


         A__										=  worda
         A__										=  worda
         A__										=  len(_SCREAMING_SNAKE_CASE       )
         A__										=  len(_SCREAMING_SNAKE_CASE       )
         A__										=  [[0 for _ in range(n + 1       )] for _ in range(m + 1       )]

         for i in range(m + 1       ):
              for j in range(n + 1       ):
                   if i == 0:  # first string is empty
                        A__										=  j
                   elif j == 0:  # second string is empty
                        A__										=  i
                   elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                        A__										=  self.dp[i - 1][j - 1]
                   else:
                        A__										=  self.dp[i][j - 1]
                        A__										=  self.dp[i - 1][j]
                        A__										=  self.dp[i - 1][j - 1]
                        A__										=  1 + min(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE       )
         return self.dp[m][n]


if __name__ == "__main__":
    SCREAMING_SNAKE_CASE_					:	str							  =						EditDistance()

    print('****************** Testing Edit Distance DP Algorithm ******************')
    print()

    SCREAMING_SNAKE_CASE_					:	Union[str, Any]							  =						input('Enter the first string: ').strip()
    SCREAMING_SNAKE_CASE_					:	str							  =						input('Enter the second string: ').strip()

    print()
    print(f"""The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}""")
    print(f"""The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}""")
    print()
    print('*************** End of Testing Edit Distance DP Algorithm ***************')









"""simple docstring"""



from __future__ import annotations



class 					a						:



    """simple docstring"""



    def __init__(     self: Any    ,						UpperCamelCase: str    ,						UpperCamelCase: str       ):






         """simple docstring"""


         A__			,				A__										=  text, pattern
         A__			,				A__										=  len(UpperCamelCase       ), len(UpperCamelCase       )

    def 				UpperCamelCase	(     self: Dict    ,						UpperCamelCase: str       ):






         """simple docstring"""


         for i in range(self.patLen - 1    ,						-1    ,						-1       ):
              if char == self.pattern[i]:
                   return i
         return -1

    def 				UpperCamelCase	(     self: str    ,						UpperCamelCase: int       ):






         """simple docstring"""


         for i in range(self.patLen - 1    ,						-1    ,						-1       ):
              if self.pattern[i] != self.text[current_pos + i]:
                   return current_pos + i
         return -1





    def 				UpperCamelCase	(     self: List[Any]       ):






         """simple docstring"""


         A__										=  []
         for i in range(self.textLen - self.patLen + 1       ):
              A__										=  self.mismatch_in_text(UpperCamelCase       )
              if mismatch_index == -1:
                   positions.append(UpperCamelCase       )
              else:
                   A__										=  self.match_in_pattern(self.text[mismatch_index]       )
                   A__										=  (
                       mismatch_index - match_index
                   )  # shifting index lgtm [py/multiple-definition]
         return positions

SCREAMING_SNAKE_CASE_					:	List[Any]							  =						'ABAABA'
SCREAMING_SNAKE_CASE_					:	List[Any]							  =						'AB'
SCREAMING_SNAKE_CASE_					:	Union[str, Any]							  =						BoyerMooreSearch(text, pattern)
SCREAMING_SNAKE_CASE_					:	int							  =						bms.bad_character_heuristic()

if len(positions) == 0:
 print('No match found')
else:
 print('Pattern found in following positions: ')
 print(positions)






