






from __future__ import annotations

from string import ascii_letters
def    a__    (	A		,					A		,					A = None       ):
   lowercase__    :						Dict       =			alphabet or ascii_letters

   # The final result string
   lowercase__    :						Any       =			""""""

   for character in input_string:
      if character not in alpha:
         # Append without encryption if character is not in the alphabet
         result += character
      else:
         # Get the index of the new key and make sure it isn't too large
         lowercase__    :						List[Any]       =			(alpha.index(A       ) + key) % len(A       )

         # Append the encoded character to the alphabet
         result += alpha[new_key]

   return result
def    a__    (	A		,					A		,					A = None       ):
   key *= -1

   return encrypt(A		,					A		,					A       )
def    a__    (	A		,					A = None       ):
   lowercase__    :						List[str]       =			alphabet or ascii_letters

   # To store data on all the combinations
   lowercase__    :						Union[str, Any]       =			{}

   # Cycle through each combination
   for key in range(1		,					len(A       ) + 1       ):
      # Decrypt the message and store the result in the data
      lowercase__    :						int       =			decrypt(A		,					A		,					A       )

   return brute_force_data


if __name__ == "__main__":
 while True:
  print(F'\n{"-" * 10}\n Menu\n{"-" * 10}')
  print(*['1.Encrypt', '2.Decrypt', '3.BruteForce', '4.Quit'], sep='\n')

  # get user input
  a 			=							input('\nWhat would you like to do?: ').strip() or '4'

  # run functions based on what the user chose
  if choice not in ("1", "2", "3", "4"):
   print('Invalid choice, please enter a valid choice')
  elif choice == "1":
   a 			=							input('Please enter the string to be encrypted: ')
   a 			=							int(input('Please enter off-set: ').strip())

   print(encrypt(input_string, key))
  elif choice == "2":
   a 			=							input('Please enter the string to be decrypted: ')
   a 			=							int(input('Please enter off-set: ').strip())

   print(decrypt(input_string, key))
  elif choice == "3":
   a 			=							input('Please enter the string to be decrypted: ')
   a 			=							brute_force(input_string)

   for key, value in brute_force_data.items():
    print(F'Key: {key} | Message: {value}')

  elif choice == "4":
   print('Goodbye.')
   break










from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
a 			=							[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
def    a__    (	A       ):
   return [int(A       ) for c in F'''{ruleset:08}'''[:8]]
def    a__    (	A		,					A		,					A       ):
   lowercase__    :						List[Any]       =			len(cells[0]       )  # 31
   lowercase__    :						int       =			[]
   for i in range(A       ):
      # Get the neighbors of each cell
      # Handle neighbours outside bounds by using 0 as their value
      lowercase__    :						Optional[Any]       =			0 if i == 0 else cells[time][i - 1]
      lowercase__    :						Dict       =			0 if i == population - 1 else cells[time][i + 1]
      # Define a new cell and add it to the new generation
      lowercase__    :						str       =			7 - int(F'''{left_neighbor}{cells[time][i]}{right_neighbor}'''		,					2       )
      next_generation.append(rule[situation]       )
   return next_generation
def    a__    (	A       ):
   lowercase__    :						Tuple       =			Image.new("""RGB"""		,					(len(cells[0]       ), len(A       ))       )
   lowercase__    :						Optional[Any]       =			img.load()
   # Generates image
   for w in range(img.width       ):
      for h in range(img.height       ):
         lowercase__    :						Union[str, Any]       =			255 - int(255 * cells[h][w]       )
         lowercase__    :						int       =			(color, color, color)
   return img


if __name__ == "__main__":
 a 			=							bin(int(input('Rule:\n').strip()))[2:]
 a 			=							format_ruleset(int(rule_num))
 for time in range(16):
  CELLS.append(new_generation(CELLS, rule, time))
 a 			=							generate_image(CELLS)
 # Uncomment to save the image
 # img.save(f"rule_{rule_num}.png")
 img.show()


