code: 
  
  
  
  
  
  
  from __future__ import annotations
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	Optional[int]     ,			A_:	Any		)  ->							str:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase    							="""""", """""", """"""
         __UpperCAmelCase    							=[]
  
         for character in message_part:
                tmp.append(character_to_number[character]		)
  
         for each in tmp:
                one += each[0]
                two += each[1]
                three += each[2]
  
         return one + two + three
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	List[str]     ,			A_:	List[str]		)  ->							tuple[str, str, str]:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase    							="""""", """"""
         __UpperCAmelCase    							=[]
  
         for character in message_part:
                this_part += character_to_number[character]
  
         for digit in this_part:
                tmp += digit
                if len(A_		) == len(A_		):
                       result.append(A_		)
                       __UpperCAmelCase    							=""""""
  
         return result[0], result[1], result[2]
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	Optional[Any]     ,			A_:	List[Any]		)  ->							tuple[str, str, dict[str, str], dict[str, str]]:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=alphabet.replace(""" """     ,			""""""		).upper()
         __UpperCAmelCase    							=message.replace(""" """     ,			""""""		).upper()
  
         # Check length and characters
         if len(A_		) != 27:
                raise KeyError("""Length of alphabet has to be 27."""		)
         for each in message:
                if each not in alphabet:
                       raise ValueError("""Each message character has to be included in alphabet!"""		)
  
      # Generate dictionares
         __UpperCAmelCase    							=(
             """111""",
             """112""",
             """113""",
             """121""",
             """122""",
             """123""",
             """131""",
             """132""",
             """133""",
             """211""",
             """212""",
             """213""",
             """221""",
             """222""",
             """223""",
             """231""",
             """232""",
             """233""",
             """311""",
             """312""",
             """313""",
             """321""",
             """322""",
             """323""",
             """331""",
             """332""",
             """333""",
         )
         __UpperCAmelCase    							={}
         __UpperCAmelCase    							={}
         for letter, number in zip(A_     ,			A_		):
                __UpperCAmelCase    							=number
                __UpperCAmelCase    							=letter
  
         return message, alphabet, character_to_number, number_to_character
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	Tuple     ,			A_:	int = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."     ,			A_:	Optional[Any] = 5		)  ->							str:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase    							=__prepare(
             A_     ,			A_		)
         __UpperCAmelCase							,   __UpperCAmelCase    							="""""", """"""
  
         for i in range(0     ,			len(A_		) + 1     ,			A_		):
                encrypted_numeric += __encrypt_part(
                    message[i : i + period]     ,			A_		)
  
         for i in range(0     ,			len(A_		)     ,			3		):
                encrypted += number_to_character[encrypted_numeric[i : i + 3]]
  
         return encrypted
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	Optional[Any]     ,			A_:	Optional[int] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."     ,			A_:	Any = 5		)  ->							str:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase    							=__prepare(
             A_     ,			A_		)
         __UpperCAmelCase    							=[]
         __UpperCAmelCase    							=""""""
  
         for i in range(0     ,			len(A_		) + 1     ,			A_		):
                __UpperCAmelCase							,   __UpperCAmelCase							,   __UpperCAmelCase    							=__decrypt_part(message[i : i + period]     ,			A_		)
  
                for j in range(0     ,			len(A_		)		):
                       decrypted_numeric.append(a[j] + b[j] + c[j]		)
  
         for each in decrypted_numeric:
                decrypted += number_to_character[each]
  
         return decrypted
  
  
  if __name__ == "__main__":
     __A  							=  "DEFEND THE EAST WALL OF THE CASTLE."
     __A  							=  encrypt_message(msg, "EPSDUCVWYM.ZLKXNBTFGORIJHAQ")
     __A  							=  decrypt_message(encrypted, "EPSDUCVWYM.ZLKXNBTFGORIJHAQ")
     print(F"""Encrypted: {encrypted}\nDecrypted: {decrypted}""")
  
  
style_context: 
  
  
  
  
  
  
  import math as m
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	Tuple     ,			A_:	str     ,			A_:	Union[str, Any]=0.0_0_1		)  ->							List[str]:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         return (f(a + h		) - f(a - h		)) / (2 * h)
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	str     ,			A_:	Union[str, Any]=0     ,			A_:	List[Any]=100     ,			A_:	Optional[Any]=0.0_0_0_1     ,			A_:	Tuple=1e-6     ,			A_:	Union[str, Any]=False		)  ->							Union[str, Any]:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=xa  # set the initial guess
         __UpperCAmelCase    							=[a]
         __UpperCAmelCase    							=abs(f(A_		)		)
         __UpperCAmelCase    							=lambda A_		: calc_derivative(A_     ,			A_     ,			h=A_		)  # noqa: E731  Derivative of f(x)
         for _ in range(A_		):
                if fa(A_		) == 0:
                       raise ValueError("""No converging solution found"""		)
                __UpperCAmelCase    							=a - f(A_		) / fa(A_		)  # Calculate the next estimate
                if logsteps:
                       steps.append(A_		)
                if error < maxerror:
                       break
         else:
                raise ValueError("""Iteration limit reached, no converging solution found"""		)
         if logsteps:
                # If logstep is true, then log intermediate steps
                return a, error, steps
         return a, error
  
  
  if __name__ == "__main__":
     from matplotlib import pyplot as plt
  
     __A  							=  lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
     __A							,    __A							,    __A  							=  newton_raphson(
         f, xa=10, maxiter=10_00, step=1E-6, logsteps=True
     )
     plt.plot([abs(f(x)) for x in steps])
     plt.xlabel("step")
     plt.ylabel("error")
     plt.show()
     print(F"""solution = {{{solution:f}}}, error = {{{error:f}}}""")
  
  
  
  
  