


class 							a						:




							"""simple docstring"""


							def __init__(				self			:    List[str]							)      ->       List[str]:
														__snake_case						:     Dict									=  ""
														__snake_case						:     str									=  ""
														__snake_case						:     int									=  []

							def        __snake_case   (				self			:    int       ,      lowerCamelCase			:    int       ,      lowerCamelCase			:    int							)      ->       int:
														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]:
																												__snake_case						:     List[str]									=  self.__min_dist_top_down_dp(m - 1       ,      n - 1							)
																					else:
																												__snake_case						:     Tuple									=  self.__min_dist_top_down_dp(lowerCamelCase       ,      n - 1							)
																												__snake_case						:     int									=  self.__min_dist_top_down_dp(m - 1       ,      lowerCamelCase							)
																												__snake_case						:     Union[str, Any]									=  self.__min_dist_top_down_dp(m - 1       ,      n - 1							)
																												__snake_case						:     int									=  1 + min(lowerCamelCase       ,      lowerCamelCase       ,      lowerCamelCase							)

																					return self.dp[m][n]

							def        __snake_case   (				self			:    str       ,      lowerCamelCase			:    str       ,      lowerCamelCase			:    str							)      ->       int:
														__snake_case						:     Tuple									=  worda
														__snake_case						:     Any									=  worda
														__snake_case						:     Optional[int]									=  [[-1 for _ in range(len(lowerCamelCase							)							)] for _ in range(len(lowerCamelCase							)							)]

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






							def        __snake_case   (				self			:    Optional[Any]       ,      lowerCamelCase			:    str       ,      lowerCamelCase			:    str							)      ->       int:
														__snake_case						:     List[Any]									=  worda
														__snake_case						:     Tuple									=  worda
														__snake_case						:     Dict									=  len(lowerCamelCase							)
														__snake_case						:     Union[str, Any]									=  len(lowerCamelCase							)
														__snake_case						:     Optional[int]									=  [[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
																																			__snake_case						:     Tuple									=  j
																												elif j == 0:  # second string is empty
																																			__snake_case						:     List[str]									=  i
																												elif worda[i - 1] == worda[j - 1]:  # last characters are equal
																																			__snake_case						:     Any									=  self.dp[i - 1][j - 1]
																												else:
																																			__snake_case						:     Union[str, Any]									=  self.dp[i][j - 1]
																																			__snake_case						:     List[str]									=  self.dp[i - 1][j]
																																			__snake_case						:     int									=  self.dp[i - 1][j - 1]
																																			__snake_case						:     Optional[int]									=  1 + min(lowerCamelCase       ,      lowerCamelCase       ,      lowerCamelCase							)
														return self.dp[m][n]


if __name__ == "__main__":
			_snake_case	:						Union[str, Any]         =							EditDistance()

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

			_snake_case	:						Dict         =							input("Enter the first string: ").strip()
			_snake_case	:						Any         =							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 ***************")



from collections.abc import Callable






def   lowerCamelCase__							(							__lowerCAmelCase    :    Callable[[float], float]       ,				__lowerCAmelCase    :    float       ,				__lowerCAmelCase    :    float							):




			"""simple docstring"""


			lowerCAmelCase_         =      a
			lowerCAmelCase_         =      b
			if function(__lowerCAmelCase							) == 0:  # one of the a or b is a root for the function
						return a
			elif function(__lowerCAmelCase							) == 0:
						return b
			elif (
			    function(__lowerCAmelCase							) * function(__lowerCAmelCase							) > 0
			):  # if none of these are root and they are both positive or negative,
						# then this algorithm can't find the root
						raise ValueError("could not find root in given interval."							)
			else:
						lowerCAmelCase_         =      start + (end - start) / 2.0
						while abs(start - mid							) > 10**-7:  # until precisely equals to 10^-7
									if function(__lowerCAmelCase							) == 0:
												return mid
									elif function(__lowerCAmelCase							) * function(__lowerCAmelCase							) < 0:
												lowerCAmelCase_         =      mid
									else:
												lowerCAmelCase_         =      mid
									lowerCAmelCase_         =      start + (end - start) / 2.0
						return mid






def   lowerCamelCase__							(							__lowerCAmelCase    :    float							):




			"""simple docstring"""


			return x**3 - 2 * x - 5


if __name__ == "__main__":
			print(bisection(f, 1, 10_00))

			import doctest

			doctest.testmod()



