



"""simple docstring"""

from __future__ import annotations

lowercase__    :  int							    =	tuple[int, int, int]
lowercase__    :  List[Any]							    =	tuple[str, str, str]


# used alphabet --------------------------
# from string.ascii_uppercase
lowercase__    :  List[Any]							    =	'''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''

# -------------------------- default selection --------------------------
# rotors --------------------------
lowercase__    :  List[Any]							    =	'''EGZWVONAHDCLFQMSIPJBYUKXTR'''
lowercase__    :  Optional[int]							    =	'''FOBHMDKEXQNRAULPGSJVTYICZW'''
lowercase__    :  int							    =	'''ZJXESIUQLHAVRMDOYGTNFWPBKC'''
# reflector --------------------------
lowercase__    :  Union[str, Any]							    =	{
    '''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__    :  Optional[int]							    =	'''RMDJXFUWGISLHVTCQNKYPBEZOA'''
lowercase__    :  Optional[Any]							    =	'''SGLCPQWZHKXAREONTFBVIYJUDM'''
lowercase__    :  Any							    =	'''HVSICLTYKQUBXDWAJZOMFGPREN'''
lowercase__    :  List[str]							    =	'''RZWQHFMVDBKICJLNTUXAGYPSOE'''
lowercase__    :  Tuple							    =	'''LFKIJODBEGAMQPXVUHYSTCZRWN'''
lowercase__    :  List[str]							    =	'''KOAEGVDHXPQZMLFTYWJNBRCIUS'''




def __lowercase			(							_a		,			_a		,			_a    ):
    # Checks if there are 3 unique rotors

    if (unique_rotsel := len(set(_a    )    )) < 3:
        snake_case_ :     Tuple				=	f"Please use 3 unique rotors (not {unique_rotsel})"
        raise Exception(_a    )

    # Checks if rotor positions are valid
    snake_case_,	snake_case_,	snake_case_ :     Tuple				=	rotpos
    if not 0 < rotorposa <= len(_a    ):
        snake_case_ :     Optional[int]				=	f"First rotor position is not within range of 1..26 ({rotorposa}"
        raise ValueError(_a    )
    if not 0 < rotorposa <= len(_a    ):
        snake_case_ :     Optional[Any]				=	f"Second rotor position is not within range of 1..26 ({rotorposa})"
        raise ValueError(_a    )
    if not 0 < rotorposa <= len(_a    ):
        snake_case_ :     List[str]				=	f"Third rotor position is not within range of 1..26 ({rotorposa})"
        raise ValueError(_a    )

    # Validates string and returns dict
    snake_case_ :     Union[str, Any]				=	_plugboard(_a    )

    return rotpos, rotsel, pbdict




def __lowercase			(							_a    ):

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

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

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

    # Created the dictionary
    snake_case_ :     Union[str, Any]				=	{}
    for j in range(0		,			len(_a    ) - 1		,			2    ):
        snake_case_ :     int				=	pbstring[j + 1]
        snake_case_ :     List[str]				=	pbstring[j]

    return pb




def __lowercase			(							_a		,			_a		,			_a = (rotora, rotora, rotora)		,			_a = ""		,			):
    snake_case_ :     str				=	text.upper()
    snake_case_,	snake_case_,	snake_case_ :     List[Any]				=	_validator(
        _a		,			_a		,			plugb.upper()    )

    snake_case_,	snake_case_,	snake_case_ :     Any				=	rotor_position
    snake_case_,	snake_case_,	snake_case_ :     Dict				=	rotor_selection
    rotorposa -= 1
    rotorposa -= 1
    rotorposa -= 1

    snake_case_ :     Dict				=	[]

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

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

            # rotor rb --------------------------
            snake_case_ :     Optional[int]				=	abc.index(_a    ) + rotorposa
            snake_case_ :     str				=	rotora[index % len(_a    )]

            # rotor rc --------------------------
            snake_case_ :     List[str]				=	abc.index(_a    ) + rotorposa
            snake_case_ :     int				=	rotora[index % len(_a    )]

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

            snake_case_ :     Optional[int]				=	reflector[symbol]

            # 2nd rotors
            snake_case_ :     Union[str, Any]				=	abc[rotora.index(_a    ) - rotorposa]
            snake_case_ :     Any				=	abc[rotora.index(_a    ) - rotorposa]
            snake_case_ :     Optional[int]				=	abc[rotora.index(_a    ) - rotorposa]

            # 2nd plugboard
            if symbol in plugboard:
                snake_case_ :     Optional[Any]				=	plugboard[symbol]

            # moves/resets rotor positions
            rotorposa += 1
            if rotorposa >= len(_a    ):
                snake_case_ :     int				=	0
                rotorposa += 1
            if rotorposa >= len(_a    ):
                snake_case_ :     Dict				=	0
                rotorposa += 1
            if rotorposa >= len(_a    ):
                snake_case_ :     Tuple				=	0

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

    return "".join(_a    )


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

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










"""simple docstring"""

from __future__ import annotations




def __lowercase			(							_a		,			_a		,			_a		,			):
    if (stress, tangential_force, area).count(0    ) != 1:
        raise ValueError('''You cannot supply more or less than 2 values'''    )
    elif stress < 0:
        raise ValueError('''Stress cannot be negative'''    )
    elif tangential_force < 0:
        raise ValueError('''Tangential Force cannot be negative'''    )
    elif area < 0:
        raise ValueError('''Area cannot be negative'''    )
    elif stress == 0:
        return (
            "stress",
            tangential_force / area,
        )
    elif tangential_force == 0:
        return (
            "tangential_force",
            stress * area,
        )
    else:
        return (
            "area",
            tangential_force / stress,
        )


if __name__ == "__main__":
     import doctest

     doctest.testmod()





