




from __future__ import annotations

from string import ascii_letters


def 				_a       (				lowerCAmelCase						,	lowerCAmelCase						,	lowerCAmelCase = None   )->  str:
  SCREAMING_SNAKE_CASE_							=       alphabet or ascii_letters

  # The final result string
  SCREAMING_SNAKE_CASE_							=       ''''''

  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
      SCREAMING_SNAKE_CASE_							=       (alpha.index(lowerCAmelCase   ) + key) % len(lowerCAmelCase   )

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

  return result


def 				_a       (				lowerCAmelCase						,	lowerCAmelCase						,	lowerCAmelCase = None   )->  str:
  key *= -1

  return encrypt(lowerCAmelCase						,	lowerCAmelCase						,	lowerCAmelCase   )


def 				_a       (				lowerCAmelCase						,	lowerCAmelCase = None   )->  dict[int, str]:
  SCREAMING_SNAKE_CASE_							=       alphabet or ascii_letters

  # To store data on all the combinations
  SCREAMING_SNAKE_CASE_							=       {}

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

  return brute_force_data


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

            # get user input
            SCREAMING_SNAKE_CASE:    Optional[int]											=   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":
                  SCREAMING_SNAKE_CASE:    int											=   input('''Please enter the string to be encrypted: ''')
                  SCREAMING_SNAKE_CASE:    List[str]											=   int(input('''Please enter off-set: ''').strip())

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

                  print(decrypt(input_string, key))
            elif choice == "3":
                  SCREAMING_SNAKE_CASE:    Optional[Any]											=   input('''Please enter the string to be decrypted: ''')
                  SCREAMING_SNAKE_CASE:    str											=   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


def 				_a       (				lowerCAmelCase						,	lowerCAmelCase   )->  Union[str, Any]:
		SCREAMING_SNAKE_CASE_							=       0
		SCREAMING_SNAKE_CASE_							=       len(lowerCAmelCase   ) - 1
		while left <= right:
				SCREAMING_SNAKE_CASE_							=       (left + right) // 2
				if left == right:
						if sorted_list[middle] < item:
								SCREAMING_SNAKE_CASE_							=       middle + 1
						break
				elif sorted_list[middle] < item:
						SCREAMING_SNAKE_CASE_							=       middle + 1
				else:
						SCREAMING_SNAKE_CASE_							=       middle - 1
		sorted_list.insert(lowerCAmelCase						,	lowerCAmelCase   )
		return sorted_list


def 				_a       (				lowerCAmelCase						,	lowerCAmelCase   )->  Any:
		SCREAMING_SNAKE_CASE_							=       []
		while left and right:
				if left[0][0] < right[0][0]:
						result.append(left.pop(0   )   )
				else:
						result.append(right.pop(0   )   )
		return result + left + right


def 				_a       (				lowerCAmelCase   )->  List[str]:
		SCREAMING_SNAKE_CASE_							=       len(lowerCAmelCase   )
		if length <= 1:
				return list_ad
		SCREAMING_SNAKE_CASE_							=       length // 2
		return merge(sortlist_ad(list_ad[:middle]   )						,	sortlist_ad(list_ad[middle:]   )   )


def 				_a       (				lowerCAmelCase   )->  list[int]:

		if len(lowerCAmelCase   ) <= 1:
				return collection
		SCREAMING_SNAKE_CASE_							=       []
		SCREAMING_SNAKE_CASE_							=       False
		for i in range(0						,	len(lowerCAmelCase   )						,	2   ):
				if i == len(lowerCAmelCase   ) - 1:
						SCREAMING_SNAKE_CASE_							=       True
				else:
						if collection[i] < collection[i + 1]:
								two_paired_list.append([collection[i], collection[i + 1]]   )
						else:
								two_paired_list.append([collection[i + 1], collection[i]]   )
		SCREAMING_SNAKE_CASE_							=       sortlist_ad(lowerCAmelCase   )
		SCREAMING_SNAKE_CASE_							=       [i[0] for i in sorted_list_ad]
		result.append(sorted_list_ad[-1][1]   )
		if has_last_odd_item:
				SCREAMING_SNAKE_CASE_							=       collection[-1]
				SCREAMING_SNAKE_CASE_							=       binary_search_insertion(lowerCAmelCase						,	lowerCAmelCase   )
		SCREAMING_SNAKE_CASE_							=       False
		for i in range(len(lowerCAmelCase   ) - 1   ):
				if result[i] == collection[-1] and has_last_odd_item:
						SCREAMING_SNAKE_CASE_							=       True
				SCREAMING_SNAKE_CASE_							=       sorted_list_ad[i][1]
				# If last_odd_item is inserted before the item's index,
				# you should forward index one more.
				if is_last_odd_item_inserted_before_this_index:
						SCREAMING_SNAKE_CASE_							=       result[: i + 2] + binary_search_insertion(result[i + 2 :]						,	lowerCAmelCase   )
				else:
						SCREAMING_SNAKE_CASE_							=       result[: i + 1] + binary_search_insertion(result[i + 1 :]						,	lowerCAmelCase   )

		return result


if __name__ == "__main__":
						SCREAMING_SNAKE_CASE:    List[str]											=   input('''Enter numbers separated by a comma:\n''').strip()
						SCREAMING_SNAKE_CASE:    Any											=   [int(item) for item in user_input.split(''',''')]
						print(merge_insertion_sort(unsorted))