




def   lowerCAmelCase						(						_lowerCAmelCase							:				list  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int		):




 """simple docstring"""







 if right <= left:
  return
 UpperCAmelCase__								=  UpperCAmelCase__								=  left
 UpperCAmelCase__								=  right
 UpperCAmelCase__								=  sorting[left]
 while i <= b:
  if sorting[i] < pivot:
   UpperCAmelCase__	,	UpperCAmelCase__								=  sorting[i], sorting[a]
   a += 1
   i += 1
  elif sorting[i] > pivot:
   UpperCAmelCase__	,	UpperCAmelCase__								=  sorting[i], sorting[b]
   b -= 1
  else:
   i += 1
 quick_sort_apartition(_lowerCAmelCase  ,							_lowerCAmelCase  ,							a - 1		)
 quick_sort_apartition(_lowerCAmelCase  ,							b + 1  ,							_lowerCAmelCase		)



def   lowerCAmelCase						(						_lowerCAmelCase							:				list  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int		):




 """simple docstring"""







 if left < right:
  UpperCAmelCase__								=  lomuto_partition(_lowerCAmelCase  ,							_lowerCAmelCase  ,							_lowerCAmelCase		)
  quick_sort_lomuto_partition(_lowerCAmelCase  ,							_lowerCAmelCase  ,							pivot_index - 1		)
  quick_sort_lomuto_partition(_lowerCAmelCase  ,							pivot_index + 1  ,							_lowerCAmelCase		)



def   lowerCAmelCase						(						_lowerCAmelCase							:				list  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int		):




 """simple docstring"""







 UpperCAmelCase__								=  sorting[right]
 UpperCAmelCase__								=  left
 for i in range(_lowerCAmelCase  ,							_lowerCAmelCase		):
  if sorting[i] < pivot:
   UpperCAmelCase__	,	UpperCAmelCase__								=  sorting[i], sorting[store_index]
   store_index += 1
 UpperCAmelCase__	,	UpperCAmelCase__								=  sorting[store_index], sorting[right]
 return store_index



def   lowerCAmelCase						(						_lowerCAmelCase							:				list		):




 """simple docstring"""







 if len(_lowerCAmelCase		) <= 1:
  return sorting
 return (
     three_way_radix_quicksort([i for i in sorting if i < sorting[0]]		)
     + [i for i in sorting if i == sorting[0]]
     + three_way_radix_quicksort([i for i in sorting if i > sorting[0]]		)
 )


if __name__ == "__main__":
  import doctest

  doctest.testmod(verbose=True)

  _lowerCAmelCase  :				Optional[int]						=				input("Enter numbers separated by a comma:\n").strip()
  _lowerCAmelCase  :				Dict						=				[int(item) for item in user_input.split(",")]
  quick_sort_apartition(unsorted, 0, len(unsorted) - 1)
  print(unsorted)











from __future__ import annotations

from string import ascii_letters



def   lowerCAmelCase						(						_lowerCAmelCase							:				str  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				str | None = None		):




 """simple docstring"""







 UpperCAmelCase__								=  alphabet or ascii_letters

 # The final result string
 UpperCAmelCase__								=  ""

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

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

 return result



def   lowerCAmelCase						(						_lowerCAmelCase							:				str  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				str | None = None		):




 """simple docstring"""







 key *= -1

 return encrypt(_lowerCAmelCase  ,							_lowerCAmelCase  ,							_lowerCAmelCase		)



def   lowerCAmelCase						(						_lowerCAmelCase							:				str  ,							_lowerCAmelCase							:				str | None = None		):




 """simple docstring"""







 UpperCAmelCase__								=  alphabet or ascii_letters

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

 # Cycle through each combination
 for key in range(1  ,							len(_lowerCAmelCase		) + 1		):
  # Decrypt the message and store the result in the data
  UpperCAmelCase__								=  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
    _lowerCAmelCase  :				List[Any]						=				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":
      _lowerCAmelCase  :				Any						=				input("Please enter the string to be encrypted: ")
      _lowerCAmelCase  :				str						=				int(input("Please enter off-set: ").strip())

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

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

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

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





