





"""simple docstring"""





import math
import unittest


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		int     ):







      '''simple docstring'''




      assert isinstance(SCREAMING_SNAKE_CASE				,		SCREAMING_SNAKE_CASE     ) and (
          number >= 0
      ), "'number' must been an int and positive"

      if 1 < number < 4:
            # 2 and 3 are primes
            return True
      elif number < 2 or number % 2 == 0 or number % 3 == 0:
            # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
            return False

      # All primes number are in format of 6k +/- 1
      for i in range(5				,		int(math.sqrt(SCREAMING_SNAKE_CASE     ) + 1     )				,		6     ):
            if number % i == 0 or number % (i + 2) == 0:
                  return False
      return True

class 						lowercase   (   unittest.TestCase   ):





      def        _snake_case     (			self					)						->	Union[str, Any]:
            self.assertTrue(is_prime(2					)					)
            self.assertTrue(is_prime(3					)					)
            self.assertTrue(is_prime(5					)					)
            self.assertTrue(is_prime(7					)					)
            self.assertTrue(is_prime(11					)					)
            self.assertTrue(is_prime(13					)					)
            self.assertTrue(is_prime(17					)					)
            self.assertTrue(is_prime(19					)					)
            self.assertTrue(is_prime(23					)					)
            self.assertTrue(is_prime(29					)					)





      def        _snake_case     (			self					)						->	Union[str, Any]:
            with self.assertRaises(lowercase					):
                  is_prime(-19					)
            self.assertFalse(
                is_prime(0					) ,		"""Zero doesn't have any positive factors, primes must have exactly two.""" ,		)
            self.assertFalse(
                is_prime(1					) ,		"""One only has 1 positive factor, primes must have exactly two.""" ,		)
            self.assertFalse(is_prime(2 * 2					)					)
            self.assertFalse(is_prime(2 * 3					)					)
            self.assertFalse(is_prime(3 * 3					)					)
            self.assertFalse(is_prime(3 * 5					)					)
            self.assertFalse(is_prime(3 * 5 * 7					)					)


if __name__ == "__main__":
       unittest.main()













"""simple docstring"""





def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		str     ):







      '''simple docstring'''




      lowerCAmelCase    		=			""""""
      for ch in key:
            if ch == " " or ch not in key_no_dups and ch.isalpha():
                  key_no_dups += ch
      return key_no_dups


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		str     ):







      '''simple docstring'''




      lowerCAmelCase    		=			[chr(i + 65     ) for i in range(26     )]
      # Remove duplicate characters from key
      lowerCAmelCase    		=			remove_duplicates(key.upper()     )
      lowerCAmelCase    		=			len(SCREAMING_SNAKE_CASE     )
      # First fill cipher with key characters
      lowerCAmelCase    		=			{alphabet[i]: char for i, char in enumerate(SCREAMING_SNAKE_CASE     )}
      # Then map remaining characters in alphabet to
      # the alphabet from the beginning
      for i in range(len(SCREAMING_SNAKE_CASE     )				,		26     ):
            lowerCAmelCase    		=			alphabet[i - offset]
            # Ensure we are not mapping letters to letters previously mapped
            while char in key:
                  offset -= 1
                  lowerCAmelCase    		=			alphabet[i - offset]
            lowerCAmelCase    		=			char
      return cipher_alphabet


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		str				,		SCREAMING_SNAKE_CASE	:		dict[str, str]     ):







      '''simple docstring'''




      return "".join(cipher_map.get(SCREAMING_SNAKE_CASE				,		SCREAMING_SNAKE_CASE     ) for ch in message.upper()     )


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		str				,		SCREAMING_SNAKE_CASE	:		dict[str, str]     ):







      '''simple docstring'''




      lowerCAmelCase    		=			{v: k for k, v in cipher_map.items()}
      return "".join(rev_cipher_map.get(SCREAMING_SNAKE_CASE				,		SCREAMING_SNAKE_CASE     ) for ch in message.upper()     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      lowerCAmelCase    		=			input("""Enter message to encode or decode: """     ).strip()
      lowerCAmelCase    		=			input("""Enter keyword: """     ).strip()
      lowerCAmelCase    		=			input("""Encipher or decipher? E/D:"""     ).strip()[0].lower()
      try:
            lowerCAmelCase    		=			{"""e""": encipher, """d""": decipher}[option]
      except KeyError:
            raise KeyError("""invalid input option"""     )
      lowerCAmelCase    		=			create_cipher_map(SCREAMING_SNAKE_CASE     )
      print(func(SCREAMING_SNAKE_CASE				,		SCREAMING_SNAKE_CASE     )     )


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       main()






