


'''simple docstring'''



__A		='ABCDEFGHIJKLMNOPQRSTUVWXYZ'







def       _UpperCamelCase (						):
			UpperCAmelCase__					:   List[str]       				=       input("""Enter message: """   )
			UpperCAmelCase__					:   str       				=       input("""Enter key [alphanumeric]: """   )
			UpperCAmelCase__					:   Optional[int]       				=       input("""Encrypt/Decrypt [e/d]: """   )

			if mode.lower().startswith("""e"""   ):
						UpperCAmelCase__					:   Optional[Any]       				=       """encrypt"""
						UpperCAmelCase__					:   Optional[int]       				=       encrypt_message(__SCREAMING_SNAKE_CASE	, __SCREAMING_SNAKE_CASE   )
			elif mode.lower().startswith("""d"""   ):
						UpperCAmelCase__					:   Dict       				=       """decrypt"""
						UpperCAmelCase__					:   Any       				=       decrypt_message(__SCREAMING_SNAKE_CASE	, __SCREAMING_SNAKE_CASE   )

			print(f'''\n{mode.title()}ed message:'''   )
			print(__SCREAMING_SNAKE_CASE   )







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):
			return translate_message(__SCREAMING_SNAKE_CASE	, __SCREAMING_SNAKE_CASE	, """encrypt"""   )







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):
			return translate_message(__SCREAMING_SNAKE_CASE	, __SCREAMING_SNAKE_CASE	, """decrypt"""   )







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__	, UpperCamelCase__   ):
			UpperCAmelCase__					:   Optional[Any]       				=       []
			UpperCAmelCase__					:   Tuple       				=       0
			UpperCAmelCase__					:   Optional[Any]       				=       key.upper()

			for symbol in message:
						UpperCAmelCase__					:   int       				=       LETTERS.find(symbol.upper()   )
						if num != -1:
									if mode == "encrypt":
												num += LETTERS.find(key[key_index]   )
									elif mode == "decrypt":
												num -= LETTERS.find(key[key_index]   )

									num %= len(__SCREAMING_SNAKE_CASE   )

									if symbol.isupper():
												translated.append(LETTERS[num]   )
									elif symbol.islower():
												translated.append(LETTERS[num].lower()   )

									key_index += 1
									if key_index == len(__SCREAMING_SNAKE_CASE   ):
												UpperCAmelCase__					:   Optional[int]       				=       0
						else:
									translated.append(__SCREAMING_SNAKE_CASE   )
			return "".join(__SCREAMING_SNAKE_CASE   )


if __name__ == "__main__":
		main()



'''simple docstring'''



import colorsys

from PIL import Image  # type: ignore







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__	, UpperCamelCase__   ):
			UpperCAmelCase__					:   Optional[Any]       				=       x
			UpperCAmelCase__					:   Optional[int]       				=       y
			for step in range(UpperCamelCase__   ):  # noqa: B007
						UpperCAmelCase__					:   List[str]       				=       a * a - b * b + x
						UpperCAmelCase__					:   Optional[int]       				=       2 * a * b + y
						UpperCAmelCase__					:   int       				=       a_new

						# divergence happens for all complex number with an absolute value
						# greater than 4
						if a * a + b * b > 4:
									break
			return step / (max_step - 1)







def       _UpperCamelCase (						UpperCamelCase__   ):
			if distance == 1:
						return (0, 0, 0)
			else:
						return (2_5_5, 2_5_5, 2_5_5)







def       _UpperCamelCase (						UpperCamelCase__   ):
			if distance == 1:
						return (0, 0, 0)
			else:
						return tuple(round(i * 2_5_5   ) for i in colorsys.hsv_to_rgb(UpperCamelCase__	, 1	, 1   )   )







def       _UpperCamelCase (						UpperCamelCase__ = 8_0_0	, UpperCamelCase__ = 6_0_0	, UpperCamelCase__ = -0.6	, UpperCamelCase__ = 0	, UpperCamelCase__ = 3.2	, UpperCamelCase__ = 5_0	, UpperCamelCase__ = True	, ):
			UpperCAmelCase__					:   str       				=       Image.new("""RGB"""	, (image_width, image_height)   )
			UpperCAmelCase__					:   Optional[int]       				=       img.load()

			# loop through the image-coordinates
			for image_x in range(UpperCamelCase__   ):
						for image_y in range(UpperCamelCase__   ):
									# determine the figure-coordinates based on the image-coordinates
									UpperCAmelCase__					:   Union[str, Any]       				=       figure_width / image_width * image_height
									UpperCAmelCase__					:   Union[str, Any]       				=       figure_center_x + (image_x / image_width - 0.5) * figure_width
									UpperCAmelCase__					:   Tuple       				=       figure_center_y + (image_y / image_height - 0.5) * figure_height

									UpperCAmelCase__					:   List[str]       				=       get_distance(UpperCamelCase__	, UpperCamelCase__	, UpperCamelCase__   )

									# color the corresponding pixel based on the selected coloring-function
									if use_distance_color_coding:
												UpperCAmelCase__					:   Any       				=       get_color_coded_rgb(UpperCamelCase__   )
									else:
												UpperCAmelCase__					:   Tuple       				=       get_black_and_white_rgb(UpperCamelCase__   )

			return img


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		# colored version, full figure
		__A		=get_image()

		# uncomment for colored version, different section, zoomed in
		# img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
		# figure_width = 0.8)

		# uncomment for black and white version, full figure
		# img = get_image(use_distance_color_coding = False)

		# uncomment to save the image
		# img.save("mandelbrot.png")

		img.show()