




class        __snake_case  :



				def __init__(      self      :		Union[str, Any]      )  ->    Optional[int]:





								'''simple docstring'''




								_lowerCAmelCase    :    Optional[int]										=      """"""
								_lowerCAmelCase    :    int										=      """"""
								_lowerCAmelCase    :    Any										=      []



				def       SCREAMING_SNAKE_CASE       (      self      :		int		,	_UpperCAmelCase      :		int		,	_UpperCAmelCase      :		int      )  ->    int:





								'''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]:
																_lowerCAmelCase    :    Dict										=      self.__min_dist_top_down_dp(m - 1		,	n - 1      )
												else:
																_lowerCAmelCase    :    List[Any]										=      self.__min_dist_top_down_dp(_UpperCAmelCase		,	n - 1      )
																_lowerCAmelCase    :    Optional[Any]										=      self.__min_dist_top_down_dp(m - 1		,	_UpperCAmelCase      )
																_lowerCAmelCase    :    int										=      self.__min_dist_top_down_dp(m - 1		,	n - 1      )
																_lowerCAmelCase    :    Dict										=      1 + min(_UpperCAmelCase		,	_UpperCAmelCase		,	_UpperCAmelCase      )

												return self.dp[m][n]



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		str      )  ->    int:





								'''simple docstring'''




								_lowerCAmelCase    :    Dict										=      worda
								_lowerCAmelCase    :    Tuple										=      worda
								_lowerCAmelCase    :    str										=      [[-1 for _ in range(len(_UpperCAmelCase      )      )] for _ in range(len(_UpperCAmelCase      )      )]

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



				def       SCREAMING_SNAKE_CASE       (      self      :		str		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		str      )  ->    int:





								'''simple docstring'''




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


if __name__ == "__main__":
	_lowerCamelCase      :  Any      						=						EditDistance()

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

	_lowerCamelCase      :  Optional[Any]      						=						input("Enter the first string: ").strip()
	_lowerCamelCase      :  Union[str, 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 __future__ import annotations
class        __snake_case  :



				def __init__(      self      :		Union[str, Any]		,	_UpperCAmelCase      :		int = 0      )  ->    Optional[int]:





								'''simple docstring'''




								_lowerCAmelCase    :    int										=      key



				def       SCREAMING_SNAKE_CASE       (      self      :		Dict		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    list[str]:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Optional[Any]										=      key or self.__key or 1

								# make sure key is an appropriate size
								key %= 255

								return [chr(ord(_UpperCAmelCase      ) ^ key      ) for ch in content]



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    list[str]:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    List[Any]										=      key or self.__key or 1

								# make sure key is an appropriate size
								key %= 255

								return [chr(ord(_UpperCAmelCase      ) ^ key      ) for ch in content]



				def       SCREAMING_SNAKE_CASE       (      self      :		Optional[Any]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    str:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Union[str, Any]										=      key or self.__key or 1

								# make sure key can be any size
								while key > 255:
												key -= 255

								# This will be returned
								_lowerCAmelCase    :    List[str]										=      """"""

								for ch in content:
												ans += chr(ord(_UpperCAmelCase      ) ^ key      )

								return ans



				def       SCREAMING_SNAKE_CASE       (      self      :		Tuple		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    str:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Any										=      key or self.__key or 1

								# make sure key can be any size
								while key > 255:
												key -= 255

								# This will be returned
								_lowerCAmelCase    :    List[Any]										=      """"""

								for ch in content:
												ans += chr(ord(_UpperCAmelCase      ) ^ key      )

								return ans



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    bool:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								try:
												with open(_UpperCAmelCase      ) as fin, open("""encrypt.out"""		,	"""w+"""      ) as fout:
																# actual encrypt-process
																for line in fin:
																				fout.write(self.encrypt_string(_UpperCAmelCase		,	_UpperCAmelCase      )      )

								except OSError:
												return False

								return True



				def       SCREAMING_SNAKE_CASE       (      self      :		Any		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    bool:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								try:
												with open(_UpperCAmelCase      ) as fin, open("""decrypt.out"""		,	"""w+"""      ) as fout:
																# actual encrypt-process
																for line in fin:
																				fout.write(self.decrypt_string(_UpperCAmelCase		,	_UpperCAmelCase      )      )

								except OSError:
												return False

								return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")

