






"""simple docstring"""





from __future__ import annotations

A__					: Dict=	tuple[int, int, int]
A__					: List[str]=	tuple[str, str, str]


# used alphabet --------------------------
# from string.ascii_uppercase
A__					: Union[str, Any]=	"""ABCDEFGHIJKLMNOPQRSTUVWXYZ"""

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







def   lowerCAmelCase_( SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE     )					->	tuple[RotorPositionT, RotorSelectionT, dict[str, str]]:
    """simple docstring"""

    if (unique_rotsel := len(set(SCREAMING_SNAKE_CASE     )     )) < 3:
        UpperCamelCase__         =    F'Please use 3 unique rotors (not {unique_rotsel})'
        raise Exception(SCREAMING_SNAKE_CASE     )

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

    # Validates string and returns dict
    UpperCamelCase__         =    _plugboard(SCREAMING_SNAKE_CASE     )

    return rotpos, rotsel, pbdict







def   lowerCAmelCase_( SCREAMING_SNAKE_CASE     )					->	dict[str, str]:
    """simple docstring"""

    if not isinstance(SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE     ):
        UpperCamelCase__         =    F'Plugboard setting isn\'t type string ({type(SCREAMING_SNAKE_CASE     )})'
        raise TypeError(SCREAMING_SNAKE_CASE     )
    elif len(SCREAMING_SNAKE_CASE     ) % 2 != 0:
        UpperCamelCase__         =    F'Odd number of symbols ({len(SCREAMING_SNAKE_CASE     )})'
        raise Exception(SCREAMING_SNAKE_CASE     )
    elif pbstring == "":
        return {}

    pbstring.replace(' ' ,	''     )

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

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

    return pb







def   lowerCAmelCase_( SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE = (rotora, rotora, rotora) ,	SCREAMING_SNAKE_CASE = "" ,	)					->	str:
    """simple docstring"""

    UpperCamelCase__         =    text.upper()
    UpperCamelCase__       ,						UpperCamelCase__       ,						UpperCamelCase__         =    _validator(
        SCREAMING_SNAKE_CASE ,	SCREAMING_SNAKE_CASE ,	plugb.upper()     )

    UpperCamelCase__       ,						UpperCamelCase__       ,						UpperCamelCase__         =    rotor_position
    UpperCamelCase__       ,						UpperCamelCase__       ,						UpperCamelCase__         =    rotor_selection
    rotorposa -= 1
    rotorposa -= 1
    rotorposa -= 1

    UpperCamelCase__         =    []

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

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

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

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

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

            UpperCamelCase__         =    reflector[symbol]

            # 2nd rotors
            UpperCamelCase__         =    abc[rotora.index(SCREAMING_SNAKE_CASE     ) - rotorposa]
            UpperCamelCase__         =    abc[rotora.index(SCREAMING_SNAKE_CASE     ) - rotorposa]
            UpperCamelCase__         =    abc[rotora.index(SCREAMING_SNAKE_CASE     ) - rotorposa]

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

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

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

    return "".join(SCREAMING_SNAKE_CASE     )


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

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












"""simple docstring"""





def   lowerCAmelCase_( SCREAMING_SNAKE_CASE					)					->	bool:
    """simple docstring"""

    UpperCamelCase__         =    (1 + 24 * n) ** 0.5
    return ((1 + root) / 6) % 1 == 0







def   lowerCAmelCase_( SCREAMING_SNAKE_CASE = 50_00					)					->	int:
    """simple docstring"""

    UpperCamelCase__         =    [(i * (3 * i - 1)) // 2 for i in range(1 ,	SCREAMING_SNAKE_CASE					)]
    for i, pentagonal_i in enumerate(SCREAMING_SNAKE_CASE					):
        for j in range(SCREAMING_SNAKE_CASE ,	len(SCREAMING_SNAKE_CASE					)					):
            UpperCamelCase__         =    pentagonal_nums[j]
            UpperCamelCase__         =    pentagonal_i + pentagonal_j
            UpperCamelCase__         =    pentagonal_j - pentagonal_i
            if is_pentagonal(SCREAMING_SNAKE_CASE					) and is_pentagonal(SCREAMING_SNAKE_CASE					):
                return b

    return -1


if __name__ == "__main__":
  print(F"""{solution() = }""")




