code: 
  
  
  
  
  
  
  from __future__ import annotations
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	str     ,			A_:	dict[str, str]		)  ->							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_:	str     ,			A_:	dict[str, 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_:	str     ,			A_:	str		)  ->							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_:	str     ,			A_:	str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."     ,			A_:	int = 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_:	str     ,			A_:	str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."     ,			A_:	int = 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: 
  
  
  
  
  
  
  from collections import namedtuple
  
  __A  							=  namedtuple("from_to", "from_ to")
  
  __A  							=  {
      "millimeter": "mm",
      "centimeter": "cm",
      "meter": "m",
      "kilometer": "km",
      "inch": "in",
      "inche": "in",  # Trailing 's' has been stripped off
      "feet": "ft",
      "foot": "ft",
      "yard": "yd",
      "mile": "mi",
  }
  
  __A  							=  {
      "mm": from_to(0.001, 10_00),
      "cm": from_to(0.01, 1_00),
      "m": from_to(1, 1),
      "km": from_to(10_00, 0.001),
      "in": from_to(0.0254, 39.3701),
      "ft": from_to(0.3048, 3.2_8084),
      "yd": from_to(0.9144, 1.0_9361),
      "mi": from_to(1609.34, 0.0_0062_1371),
  }
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	float     ,			A_:	str     ,			A_:	str		)  ->							float:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=from_type.lower().rstrip("""s"""		)
         __UpperCAmelCase    							=TYPE_CONVERSION.get(A_     ,			A_		)
         __UpperCAmelCase    							=to_type.lower().rstrip("""s"""		)
         __UpperCAmelCase    							=TYPE_CONVERSION.get(A_     ,			A_		)
         if new_from not in METRIC_CONVERSION:
                __UpperCAmelCase    							=(
                    F'''Invalid \'from_type\' value: {from_type!r}.\n'''
                    F'''Conversion abbreviations are: {", ".join(A_		)}'''
                )
                raise ValueError(A_		)
         if new_to not in METRIC_CONVERSION:
                __UpperCAmelCase    							=(
                    F'''Invalid \'to_type\' value: {to_type!r}.\n'''
                    F'''Conversion abbreviations are: {", ".join(A_		)}'''
                )
                raise ValueError(A_		)
         return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to
  
  
  if __name__ == "__main__":
     import doctest
  
     doctest.testmod()
  
  
  
  
  