





from collections.abc import Sequence





def      _lowercase					(						_UpperCAmelCase			,      _UpperCAmelCase				)						->  float:
				return sum(c * (x**i) for i, c in enumerate(_UpperCAmelCase				)				)





def      _lowercase					(						_UpperCAmelCase			,      _UpperCAmelCase				)						->  float:
				lowerCamelCase	 =0.0
				for coeff in reversed(_UpperCAmelCase				):
								lowerCamelCase	 =result * x + coeff
				return result


if __name__ == "__main__":
							UpperCAmelCase__						:			Dict									=(0.0, 0.0, 5.0, 9.3, 7.0)
							UpperCAmelCase__						:			Tuple									=10.0
							print(evaluate_poly(poly, x))
							print(horner(poly, x))












from __future__ import annotations

UpperCAmelCase__						:			str									=tuple[int, int, int]
UpperCAmelCase__						:			str									=tuple[str, str, str]


# used alphabet --------------------------
# from string.ascii_uppercase
UpperCAmelCase__						:			int									='''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''

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





def      _lowercase					(						_UpperCAmelCase			,      _UpperCAmelCase			,      _UpperCAmelCase				)						->  tuple[RotorPositionT, RotorSelectionT, dict[str, str]]:
				# Checks if there are 3 unique rotors

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

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

				# Validates string and returns dict
				lowerCamelCase	 =_plugboard(_UpperCAmelCase				)

				return rotpos, rotsel, pbdict





def      _lowercase					(						_UpperCAmelCase				)						->  dict[str, str]:

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

				pbstring.replace(""" """			,      """"""				)

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

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

				return pb





def      _lowercase					(						_UpperCAmelCase			,      _UpperCAmelCase			,      _UpperCAmelCase = (rotora, rotora, rotora)			,      _UpperCAmelCase = ""			,      )						->  str:
				lowerCamelCase	 =text.upper()
				lowerCamelCase ,  lowerCamelCase ,  lowerCamelCase	 =_validator(
				    _UpperCAmelCase			,      _UpperCAmelCase			,      plugb.upper()				)

				lowerCamelCase ,  lowerCamelCase ,  lowerCamelCase	 =rotor_position
				lowerCamelCase ,  lowerCamelCase ,  lowerCamelCase	 =rotor_selection
				rotorposa -= 1
				rotorposa -= 1
				rotorposa -= 1

				lowerCamelCase	 =[]

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

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

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

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

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

												lowerCamelCase	 =reflector[symbol]

												# 2nd rotors
												lowerCamelCase	 =abc[rotora.index(_UpperCAmelCase				) - rotorposa]
												lowerCamelCase	 =abc[rotora.index(_UpperCAmelCase				) - rotorposa]
												lowerCamelCase	 =abc[rotora.index(_UpperCAmelCase				) - rotorposa]

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

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

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

				return "".join(_UpperCAmelCase				)


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

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





