




from __future__ import annotations

__a							     =					tuple[int, int, int]
__a							     =					tuple[str, str, str]


# used alphabet --------------------------
# from string.ascii_uppercase
__a							     =					'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

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







def lowerCamelCase__  (     _lowercase					,		_lowercase					,		_lowercase ):

     '''simple docstring'''


     if (unique_rotsel := len(set(_lowercase ) )) < 3:
          UpperCAmelCase_     :				List[str]  =     f'''Please use 3 unique rotors (not {unique_rotsel})'''
          raise Exception(_lowercase )

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

     # Validates string and returns dict
     UpperCAmelCase_     :				int  =     _plugboard(_lowercase )

     return rotpos, rotsel, pbdict







def lowerCamelCase__  (     _lowercase ):

     '''simple docstring'''


     if not isinstance(_lowercase					,		_lowercase ):
          UpperCAmelCase_     :				Union[str, Any]  =     f'''Plugboard setting isn\'t type string ({type(_lowercase )})'''
          raise TypeError(_lowercase )
     elif len(_lowercase ) % 2 != 0:
          UpperCAmelCase_     :				Optional[int]  =     f'''Odd number of symbols ({len(_lowercase )})'''
          raise Exception(_lowercase )
     elif pbstring == "":
          return {}

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

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

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

     return pb







def lowerCamelCase__  (     _lowercase					,		_lowercase					,		_lowercase = (rotora, rotora, rotora)					,		_lowercase = ""					,		):

     '''simple docstring'''


     UpperCAmelCase_     :				Dict  =     text.upper()
     UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				Tuple  =     _validator(
         _lowercase					,		_lowercase					,		plugb.upper() )

     UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				int  =     rotor_position
     UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				Union[str, Any]  =     rotor_selection
     rotorposa -= 1
     rotorposa -= 1
     rotorposa -= 1

     UpperCAmelCase_     :				Tuple  =     []

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

               # rotor ra --------------------------
               UpperCAmelCase_     :				Tuple  =     abc.index(_lowercase ) + rotorposa
               UpperCAmelCase_     :				Union[str, Any]  =     rotora[index % len(_lowercase )]

               # rotor rb --------------------------
               UpperCAmelCase_     :				Optional[int]  =     abc.index(_lowercase ) + rotorposa
               UpperCAmelCase_     :				Optional[Any]  =     rotora[index % len(_lowercase )]

               # rotor rc --------------------------
               UpperCAmelCase_     :				int  =     abc.index(_lowercase ) + rotorposa
               UpperCAmelCase_     :				int  =     rotora[index % len(_lowercase )]

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

               UpperCAmelCase_     :				Optional[Any]  =     reflector[symbol]

               # 2nd rotors
               UpperCAmelCase_     :				int  =     abc[rotora.index(_lowercase ) - rotorposa]
               UpperCAmelCase_     :				Union[str, Any]  =     abc[rotora.index(_lowercase ) - rotorposa]
               UpperCAmelCase_     :				List[str]  =     abc[rotora.index(_lowercase ) - rotorposa]

               # 2nd plugboard
               if symbol in plugboard:
                    UpperCAmelCase_     :				Dict  =     plugboard[symbol]

               # moves/resets rotor positions
               rotorposa += 1
               if rotorposa >= len(_lowercase ):
                    UpperCAmelCase_     :				Dict  =     0
                    rotorposa += 1
               if rotorposa >= len(_lowercase ):
                    UpperCAmelCase_     :				List[Any]  =     0
                    rotorposa += 1
               if rotorposa >= len(_lowercase ):
                    UpperCAmelCase_     :				List[str]  =     0

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

     return "".join(_lowercase )


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

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





from functools import reduce

__a							     =					(
    '73167176531330624919225119674426574742355349194934'
    '96983520312774506326239578318016984801869478851843'
    '85861560789112949495459501737958331952853208805511'
    '12540698747158523863050715693290963295227443043557'
    '66896648950445244523161731856403098711121722383113'
    '62229893423380308135336276614282806444486645238749'
    '30358907296290491560440772390713810515859307960866'
    '70172427121883998797908792274921901699720888093776'
    '65727333001053367881220235421809751254540594752243'
    '52584907711670556013604839586446706324415722155397'
    '53697817977846174064955149290862569321978468622482'
    '83972241375657056057490261407972968652414535100474'
    '82166370484403199890008895243450658541227588666881'
    '16427171479924442928230863465674813919123162824586'
    '17866458359124566529476545682848912883142607690042'
    '24219022671055626321111109370544217506941658960408'
    '07198403850962455444362981230987879927244284909188'
    '84580156166097919133875499200524063689912560717606'
    '05886116467109405077541002256983155200055935729725'
    '71636269561882670428252483600823257530420752963450'
)







def lowerCamelCase__  (     _lowercase = N ):

     '''simple docstring'''


     return max(
         # mypy cannot properly interpret reduce
         int(reduce(lambda _lowercase					,		_lowercase : str(int(_lowercase ) * int(_lowercase ) )					,		n[i : i + 13] ) )
         for i in range(len(_lowercase ) - 12 ) )


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