




"""simple docstring"""






from __future__ import annotations

lowercase__			=		tuple[int, int, int]
lowercase__			=		tuple[str, str, str]


# used alphabet --------------------------
# from string.ascii_uppercase
lowercase__			=		"""ABCDEFGHIJKLMNOPQRSTUVWXYZ"""

# -------------------------- default selection --------------------------
# rotors --------------------------
lowercase__			=		"""EGZWVONAHDCLFQMSIPJBYUKXTR"""
lowercase__			=		"""FOBHMDKEXQNRAULPGSJVTYICZW"""
lowercase__			=		"""ZJXESIUQLHAVRMDOYGTNFWPBKC"""
# reflector --------------------------
lowercase__			=		{
    """A""": """N""",
    """N""": """A""",
    """B""": """O""",
    """O""": """B""",
    """C""": """P""",
    """P""": """C""",
    """D""": """Q""",
    """Q""": """D""",
    """E""": """R""",
    """R""": """E""",
    """F""": """S""",
    """S""": """F""",
    """G""": """T""",
    """T""": """G""",
    """H""": """U""",
    """U""": """H""",
    """I""": """V""",
    """V""": """I""",
    """J""": """W""",
    """W""": """J""",
    """K""": """X""",
    """X""": """K""",
    """L""": """Y""",
    """Y""": """L""",
    """M""": """Z""",
    """Z""": """M""",
}

# -------------------------- extra rotors --------------------------
lowercase__			=		"""RMDJXFUWGISLHVTCQNKYPBEZOA"""
lowercase__			=		"""SGLCPQWZHKXAREONTFBVIYJUDM"""
lowercase__			=		"""HVSICLTYKQUBXDWAJZOMFGPREN"""
lowercase__			=		"""RZWQHFMVDBKICJLNTUXAGYPSOE"""
lowercase__			=		"""LFKIJODBEGAMQPXVUHYSTCZRWN"""
lowercase__			=		"""KOAEGVDHXPQZMLFTYWJNBRCIUS"""







def 	_snake_case     (							lowercase__				,       lowercase__				,       lowercase__						):
				# Checks if there are 3 unique rotors

				if (unique_rotsel := len(set(lowercase__						)						)) < 3:
								_lowerCamelCase	:     Optional[Any]       =       f'''Please use 3 unique rotors (not {unique_rotsel})'''
								raise Exception(lowercase__						)

				# Checks if rotor positions are valid
				_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	:     Any       =       rotpos
				if not 0 < rotorposa <= len(lowercase__						):
								_lowerCamelCase	:     int       =       f'''First rotor position is not within range of 1..26 ({rotorposa}'''
								raise ValueError(lowercase__						)
				if not 0 < rotorposa <= len(lowercase__						):
								_lowerCamelCase	:     Any       =       f'''Second rotor position is not within range of 1..26 ({rotorposa})'''
								raise ValueError(lowercase__						)
				if not 0 < rotorposa <= len(lowercase__						):
								_lowerCamelCase	:     Dict       =       f'''Third rotor position is not within range of 1..26 ({rotorposa})'''
								raise ValueError(lowercase__						)

				# Validates string and returns dict
				_lowerCamelCase	:     Optional[int]       =       _plugboard(lowercase__						)

				return rotpos, rotsel, pbdict







def 	_snake_case     (							lowercase__						):

				# tests the input string if it
				# a) is type string
				# b) has even length (so pairs can be made)
				if not isinstance(lowercase__				,       lowercase__						):
								_lowerCamelCase	:     List[str]       =       f'''Plugboard setting isn\'t type string ({type(lowercase__						)})'''
								raise TypeError(lowercase__						)
				elif len(lowercase__						) % 2 != 0:
								_lowerCamelCase	:     int       =       f'''Odd number of symbols ({len(lowercase__						)})'''
								raise Exception(lowercase__						)
				elif pbstring == "":
								return {}

				pbstring.replace(' '				,       ''						)

				# Checks if all characters are unique
				_lowerCamelCase	:     List[str]       =       set()
				for i in pbstring:
								if i not in abc:
												_lowerCamelCase	:     Any       =       f'''\'{i}\' not in list of symbols'''
												raise Exception(lowercase__						)
								elif i in tmppbl:
												_lowerCamelCase	:     List[Any]       =       f'''Duplicate symbol ({i})'''
												raise Exception(lowercase__						)
								else:
												tmppbl.add(lowercase__						)
				del tmppbl

				# Created the dictionary
				_lowerCamelCase	:     str       =       {}
				for j in range(0				,       len(lowercase__						) - 1				,       2						):
								_lowerCamelCase	:     Dict       =       pbstring[j + 1]
								_lowerCamelCase	:     List[str]       =       pbstring[j]

				return pb







def 	_snake_case     (							lowercase__				,       lowercase__				,       lowercase__ = (rotora, rotora, rotora)				,       lowercase__ = ""				,       ):
				_lowerCamelCase	:     List[str]       =       text.upper()
				_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	:     Tuple       =       _validator(
				    lowercase__				,       lowercase__				,       plugb.upper()						)

				_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	:     List[Any]       =       rotor_position
				_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	:     Union[str, Any]       =       rotor_selection
				rotorposa -= 1
				rotorposa -= 1
				rotorposa -= 1

				_lowerCamelCase	:     Tuple       =       []

				# encryption/decryption process --------------------------
				for symbol in text:
								if symbol in abc:
												# 1st plugboard --------------------------
												if symbol in plugboard:
																_lowerCamelCase	:     int       =       plugboard[symbol]

												# rotor ra --------------------------
												_lowerCamelCase	:     Any       =       abc.index(lowercase__						) + rotorposa
												_lowerCamelCase	:     Dict       =       rotora[index % len(lowercase__						)]

												# rotor rb --------------------------
												_lowerCamelCase	:     Any       =       abc.index(lowercase__						) + rotorposa
												_lowerCamelCase	:     Dict       =       rotora[index % len(lowercase__						)]

												# rotor rc --------------------------
												_lowerCamelCase	:     List[Any]       =       abc.index(lowercase__						) + rotorposa
												_lowerCamelCase	:     List[str]       =       rotora[index % len(lowercase__						)]

												# reflector --------------------------
												# this is the reason you don't need another machine to decipher

												_lowerCamelCase	:     Optional[Any]       =       reflector[symbol]

												# 2nd rotors
												_lowerCamelCase	:     List[str]       =       abc[rotora.index(lowercase__						) - rotorposa]
												_lowerCamelCase	:     Dict       =       abc[rotora.index(lowercase__						) - rotorposa]
												_lowerCamelCase	:     int       =       abc[rotora.index(lowercase__						) - rotorposa]

												# 2nd plugboard
												if symbol in plugboard:
																_lowerCamelCase	:     Union[str, Any]       =       plugboard[symbol]

												# moves/resets rotor positions
												rotorposa += 1
												if rotorposa >= len(lowercase__						):
																_lowerCamelCase	:     int       =       0
																rotorposa += 1
												if rotorposa >= len(lowercase__						):
																_lowerCamelCase	:     int       =       0
																rotorposa += 1
												if rotorposa >= len(lowercase__						):
																_lowerCamelCase	:     List[Any]       =       0

        # else:
        #    pass
        #    Error could be also raised
        #    raise ValueError(
        #       'Invalid symbol('+repr(symbol)+')')
								result.append(lowercase__						)

				return "".join(lowercase__						)


if __name__ == "__main__":
			lowercase__			=		"""This is my Python script that emulates the Enigma machine from WWII."""
			lowercase__			=		(1, 1, 1)
			lowercase__			=		"""pictures"""
			lowercase__			=		(rotora, rotora, rotora)
			lowercase__			=		enigma(message, rotor_pos, rotor_sel, pb)

			print("""Encrypted message:""", en)
			print("""Decrypted message:""", enigma(en, rotor_pos, rotor_sel, pb))





"""simple docstring"""






import qiskit







def 	_snake_case     (							lowercase__ = 2						):
				_lowerCamelCase	:     Optional[Any]       =       qubits

				# Using Aer's simulator
				_lowerCamelCase	:     Dict       =       qiskit.Aer.get_backend('aer_simulator'						)

				# Creating a Quantum Circuit acting on the q register
				_lowerCamelCase	:     Dict       =       qiskit.QuantumCircuit(lowercase__				,       lowercase__						)

				# Adding a H gate on qubit 0 (now q0 in superposition)
				circuit.h(0						)

				for i in range(1				,       lowercase__						):
								# Adding CX (CNOT) gate
								circuit.cx(i - 1				,       lowercase__						)

				# Mapping the quantum measurement to the classical bits
				circuit.measure(list(range(lowercase__						)						)				,       list(range(lowercase__						)						)						)

				# Now measuring any one qubit would affect other qubits to collapse
				# their super position and have same state as the measured one.

				# Executing the circuit on the simulator
				_lowerCamelCase	:     Optional[Any]       =       qiskit.execute(lowercase__				,       lowercase__				,       shots=1000						)

				return job.result().get_counts(lowercase__						)


if __name__ == "__main__":
			print(F"Total count for various states are: {quantum_entanglement(3)}")