




from __future__ import annotations

__SCREAMING_SNAKE_CASE 						=tuple[int, int, int]
__SCREAMING_SNAKE_CASE 						=tuple[str, str, str]


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

# -------------------------- default selection --------------------------
# rotors --------------------------
__SCREAMING_SNAKE_CASE 						="""EGZWVONAHDCLFQMSIPJBYUKXTR"""
__SCREAMING_SNAKE_CASE 						="""FOBHMDKEXQNRAULPGSJVTYICZW"""
__SCREAMING_SNAKE_CASE 						="""ZJXESIUQLHAVRMDOYGTNFWPBKC"""
# reflector --------------------------
__SCREAMING_SNAKE_CASE 						={
    """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 --------------------------
__SCREAMING_SNAKE_CASE 						="""RMDJXFUWGISLHVTCQNKYPBEZOA"""
__SCREAMING_SNAKE_CASE 						="""SGLCPQWZHKXAREONTFBVIYJUDM"""
__SCREAMING_SNAKE_CASE 						="""HVSICLTYKQUBXDWAJZOMFGPREN"""
__SCREAMING_SNAKE_CASE 						="""RZWQHFMVDBKICJLNTUXAGYPSOE"""
__SCREAMING_SNAKE_CASE 						="""LFKIJODBEGAMQPXVUHYSTCZRWN"""
__SCREAMING_SNAKE_CASE 						="""KOAEGVDHXPQZMLFTYWJNBRCIUS"""

def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							# Checks if there are 3 unique rotors

							if (unique_rotsel := len(set(_lowerCAmelCase     )     )) < 3:
														SCREAMING_SNAKE_CASE_   	=    F"Please use 3 unique rotors (not {unique_rotsel})"
														raise Exception(_lowerCAmelCase     )

							# Checks if rotor positions are valid
							SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_   	=    rotpos
							if not 0 < rotorposa <= len(_lowerCAmelCase     ):
														SCREAMING_SNAKE_CASE_   	=    F"First rotor position is not within range of 1..26 ({rotorposa}"
														raise ValueError(_lowerCAmelCase     )
							if not 0 < rotorposa <= len(_lowerCAmelCase     ):
														SCREAMING_SNAKE_CASE_   	=    F"Second rotor position is not within range of 1..26 ({rotorposa})"
														raise ValueError(_lowerCAmelCase     )
							if not 0 < rotorposa <= len(_lowerCAmelCase     ):
														SCREAMING_SNAKE_CASE_   	=    F"Third rotor position is not within range of 1..26 ({rotorposa})"
														raise ValueError(_lowerCAmelCase     )

							# Validates string and returns dict
							SCREAMING_SNAKE_CASE_   	=    _plugboard(_lowerCAmelCase     )

							return rotpos, rotsel, pbdict

def 			a   (_lowerCAmelCase     ):

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

							pbstring.replace(''' '''  ,    ''''''     )

							# Checks if all characters are unique
							SCREAMING_SNAKE_CASE_   	=    set()
							for i in pbstring:
														if i not in abc:
																					SCREAMING_SNAKE_CASE_   	=    F"'{i}' not in list of symbols"
																					raise Exception(_lowerCAmelCase     )
														elif i in tmppbl:
																					SCREAMING_SNAKE_CASE_   	=    F"Duplicate symbol ({i})"
																					raise Exception(_lowerCAmelCase     )
														else:
																					tmppbl.add(_lowerCAmelCase     )
							del tmppbl

							# Created the dictionary
							SCREAMING_SNAKE_CASE_   	=    {}
							for j in range(0  ,    len(_lowerCAmelCase     ) - 1  ,    2     ):
														SCREAMING_SNAKE_CASE_   	=    pbstring[j + 1]
														SCREAMING_SNAKE_CASE_   	=    pbstring[j]

							return pb

def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase = (rotora, rotora, rotora)  ,    _lowerCAmelCase = ""  ,    ):
							SCREAMING_SNAKE_CASE_   	=    text.upper()
							SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_   	=    _validator(
							    _lowerCAmelCase  ,    _lowerCAmelCase  ,    plugb.upper()     )

							SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_   	=    rotor_position
							SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_   	=    rotor_selection
							rotorposa -= 1
							rotorposa -= 1
							rotorposa -= 1

							SCREAMING_SNAKE_CASE_   	=    []

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

																					# rotor ra --------------------------
																					SCREAMING_SNAKE_CASE_   	=    abc.index(_lowerCAmelCase     ) + rotorposa
																					SCREAMING_SNAKE_CASE_   	=    rotora[index % len(_lowerCAmelCase     )]

																					# rotor rb --------------------------
																					SCREAMING_SNAKE_CASE_   	=    abc.index(_lowerCAmelCase     ) + rotorposa
																					SCREAMING_SNAKE_CASE_   	=    rotora[index % len(_lowerCAmelCase     )]

																					# rotor rc --------------------------
																					SCREAMING_SNAKE_CASE_   	=    abc.index(_lowerCAmelCase     ) + rotorposa
																					SCREAMING_SNAKE_CASE_   	=    rotora[index % len(_lowerCAmelCase     )]

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

																					SCREAMING_SNAKE_CASE_   	=    reflector[symbol]

																					# 2nd rotors
																					SCREAMING_SNAKE_CASE_   	=    abc[rotora.index(_lowerCAmelCase     ) - rotorposa]
																					SCREAMING_SNAKE_CASE_   	=    abc[rotora.index(_lowerCAmelCase     ) - rotorposa]
																					SCREAMING_SNAKE_CASE_   	=    abc[rotora.index(_lowerCAmelCase     ) - rotorposa]

																					# 2nd plugboard
																					if symbol in plugboard:
																												SCREAMING_SNAKE_CASE_   	=    plugboard[symbol]

																					# moves/resets rotor positions
																					rotorposa += 1
																					if rotorposa >= len(_lowerCAmelCase     ):
																												SCREAMING_SNAKE_CASE_   	=    0
																												rotorposa += 1
																					if rotorposa >= len(_lowerCAmelCase     ):
																												SCREAMING_SNAKE_CASE_   	=    0
																												rotorposa += 1
																					if rotorposa >= len(_lowerCAmelCase     ):
																												SCREAMING_SNAKE_CASE_   	=    0

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

							return "".join(_lowerCAmelCase     )


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

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








from __future__ import annotations

from math import pi

# Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of
# Pi and the function
__SCREAMING_SNAKE_CASE 						=1.0_5_4_5_7_1_8_1_7e-3_4  # unit of ℏ : J * s

__SCREAMING_SNAKE_CASE 						=3e8  # unit of c : m * s^-1

def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):

							if (force, area, distance).count(0     ) != 1:
														raise ValueError('''One and only one argument must be 0'''     )
							if force < 0:
														raise ValueError('''Magnitude of force can not be negative'''     )
							if distance < 0:
														raise ValueError('''Distance can not be negative'''     )
							if area < 0:
														raise ValueError('''Area can not be negative'''     )
							if force == 0:
														SCREAMING_SNAKE_CASE_   	=    (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (
														    2_4_0 * (distance) ** 4
														)
														return {"force": force}
							elif area == 0:
														SCREAMING_SNAKE_CASE_   	=    (2_4_0 * force * (distance) ** 4) / (
														    REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2
														)
														return {"area": area}
							elif distance == 0:
														SCREAMING_SNAKE_CASE_   	=    (
														    (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (2_4_0 * force)
														) ** (1 / 4)
														return {"distance": distance}
							raise ValueError('''One and only one argument must be 0'''     )


# Run doctest
if __name__ == "__main__":
			import doctest

			doctest.testmod()


