
'''simple docstring'''



def A				(__lowerCamelCase				:List[Any]			,     __lowerCamelCase				:List[Any]		):
						_lowerCAmelCase  						=			""""""
						for i in table:
												res += inp[i - 1]
						return res


def A				(__lowerCamelCase				:Dict		):
						return data[1:] + data[0]


def A				(__lowerCamelCase				:Tuple			,     __lowerCamelCase				:Optional[Any]		):
						_lowerCAmelCase  						=			""""""
						for i in range(len(__lowerCamelCase		)		):
												if a[i] == b[i]:
																		res += "0"
												else:
																		res += "1"
						return res


def A				(__lowerCamelCase				:Optional[int]			,     __lowerCamelCase				:List[str]		):
						_lowerCAmelCase  						=			int("""0b""" + data[0] + data[-1]			,     2		)
						_lowerCAmelCase  						=			int("""0b""" + data[1:3]			,     2		)
						return bin(s[row][col]		)[2:]


def A				(__lowerCamelCase				:Optional[int]			,     __lowerCamelCase				:str			,     __lowerCamelCase				:List[str]			,     __lowerCamelCase				:Optional[Any]			,     __lowerCamelCase				:Tuple		):
						_lowerCAmelCase  						=			message[:4]
						_lowerCAmelCase  						=			message[4:]
						_lowerCAmelCase  						=			apply_table(__lowerCamelCase			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			xor(__lowerCamelCase			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			apply_sbox(__lowerCamelCase			,     temp[:4]		)  # noqa: E741
						_lowerCAmelCase  						=			apply_sbox(__lowerCamelCase			,     temp[4:]		)
						_lowerCAmelCase  						=			"""0""" * (2 - len(__lowerCamelCase		)) + l  # noqa: E741
						_lowerCAmelCase  						=			"""0""" * (2 - len(__lowerCamelCase		)) + r
						_lowerCAmelCase  						=			apply_table(l + r			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			xor(__lowerCamelCase			,     __lowerCamelCase		)
						return temp + right


if __name__ == "__main__":
						_lowercase    =		input("""Enter 10 bit key: """)
						_lowercase    =		input("""Enter 8 bit message: """)

						_lowercase    =		[6, 3, 7, 4, 8, 5, 10, 9]
						_lowercase    =		[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
						_lowercase    =		[2, 4, 3, 1]
						_lowercase    =		[2, 6, 3, 1, 4, 8, 5, 7]
						_lowercase    =		[4, 1, 3, 5, 7, 2, 8, 6]
						_lowercase    =		[4, 1, 2, 3, 2, 3, 4, 1]
						_lowercase    =		[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
						_lowercase    =		[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

						# key generation
						_lowercase    =		apply_table(key, paa_table)
						_lowercase    =		temp[:5]
						_lowercase    =		temp[5:]
						_lowercase    =		left_shift(left)
						_lowercase    =		left_shift(right)
						_lowercase    =		apply_table(left + right, pa_table)
						_lowercase    =		left_shift(left)
						_lowercase    =		left_shift(right)
						_lowercase    =		left_shift(left)
						_lowercase    =		left_shift(right)
						_lowercase    =		apply_table(left + right, pa_table)

						# encryption
						_lowercase    =		apply_table(message, IP)
						_lowercase    =		function(expansion, sa, sa, keya, temp)
						_lowercase    =		temp[4:] + temp[:4]
						_lowercase    =		function(expansion, sa, sa, keya, temp)
						_lowercase    =		apply_table(temp, IP_inv)
						print("""Cipher text is:""", CT)

						# decryption
						_lowercase    =		apply_table(CT, IP)
						_lowercase    =		function(expansion, sa, sa, keya, temp)
						_lowercase    =		temp[4:] + temp[:4]
						_lowercase    =		function(expansion, sa, sa, keya, temp)
						_lowercase    =		apply_table(temp, IP_inv)
						print("""Plain text after decypting is:""", PT)


'''simple docstring'''



from __future__ import annotations




class   UpperCAmelCase_					:






						'''simple docstring'''






						def __init__( self   ,       _lowercase				):

												"""simple docstring"""



												_lowerCAmelCase  						=			order

												# a_{0} ... a_{k}
												_lowerCAmelCase  						=			[1.0] + [0.0] * order
												# b_{0} ... b_{k}
												_lowerCAmelCase  						=			[1.0] + [0.0] * order

												# x[n-1] ... x[n-k]
												_lowerCAmelCase  						=			[0.0] * self.order
												# y[n-1] ... y[n-k]
												_lowerCAmelCase  						=			[0.0] * self.order




						def  _lowercase     ( self   ,       _lowercase   ,       _lowercase				):

												"""simple docstring"""



												if len(_lowercase				) < self.order:
																		_lowerCAmelCase  						=			[1.0, *a_coeffs]

												if len(_lowercase				) != self.order + 1:
																		_lowerCAmelCase  						=			(
																		    F'Expected a_coeffs to have {self.order + 1} elements '
																		    F'for {self.order}-order filter, got {len(_lowercase				)}'
																		)
																		raise ValueError(_lowercase				)

												if len(_lowercase				) != self.order + 1:
																		_lowerCAmelCase  						=			(
																		    F'Expected b_coeffs to have {self.order + 1} elements '
																		    F'for {self.order}-order filter, got {len(_lowercase				)}'
																		)
																		raise ValueError(_lowercase				)

												_lowerCAmelCase  						=			a_coeffs
												_lowerCAmelCase  						=			b_coeffs




						def  _lowercase     ( self   ,       _lowercase				):

												"""simple docstring"""



												_lowerCAmelCase  						=			0.0

												# Start at index 1 and do index 0 at the end.
												for i in range(1   ,       self.order + 1				):
																		result += (
																		    self.b_coeffs[i] * self.input_history[i - 1]
																		    - self.a_coeffs[i] * self.output_history[i - 1]
																		)

												_lowerCAmelCase  						=			(result + self.b_coeffs[0] * sample) / self.a_coeffs[0]

												_lowerCAmelCase  						=			self.input_history[:-1]
												_lowerCAmelCase  						=			self.output_history[:-1]

												_lowerCAmelCase  						=			sample
												_lowerCAmelCase  						=			result

												return result
