
import qiskit
from qiskit.providers import Backend




def 						A_			(				snake_case				: int			,   snake_case				: int			)   ->     tuple[qiskit.QuantumCircuit, str, str]:



						'''simple docstring'''

						__UpperCamelCase	,				__UpperCamelCase  	=      bin(snake_case			)[2:], bin(snake_case			)[2:]  # Remove leading '0b'

						# Ensure that both strings are of the same length
						if len(snake_case			) > len(snake_case			):
												__UpperCamelCase  	=      y.zfill(len(snake_case			)			)
						else:
												__UpperCamelCase  	=      x.zfill(len(snake_case			)			)

						# We need (3 * number of bits in the larger number)+1 qBits
						# The second parameter is the number of classical registers, to measure the result
						__UpperCamelCase  	=      qiskit.QuantumCircuit((len(snake_case			) * 3) + 1			,   len(snake_case			) + 1			)

						# We are essentially "not-ing" the bits that are 1
						# Reversed because it's easier to perform ops on more significant bits
						for i in range(len(snake_case			)			):
												if x[::-1][i] == "1":
																		circuit.x(snake_case			)
						for j in range(len(snake_case			)			):
												if y[::-1][j] == "1":
																		circuit.x(len(snake_case			) + j			)

						return circuit, x, y




def 						A_			(				snake_case				: qiskit.QuantumCircuit			,   snake_case				: int			,   snake_case				: int			,   snake_case				: int			,   snake_case				: int			,   )   ->     List[Any]:



						'''simple docstring'''

						circuit.ccx(snake_case			,   snake_case			,   snake_case			)
						circuit.cx(snake_case			,   snake_case			)
						circuit.ccx(snake_case			,   snake_case			,   snake_case			)
						circuit.cx(snake_case			,   snake_case			)
						circuit.cx(snake_case			,   snake_case			)




def 						A_			(				snake_case				: int			,   snake_case				: int			,   snake_case				: Backend = qiskit.Aer.get_backend('''aer_simulator'''			)			,   )   ->     int:



						'''simple docstring'''

						if vala < 0 or vala < 0:
												raise ValueError('''Both Integers must be positive!'''			)

						# Store the Integers
						__UpperCamelCase	,				__UpperCamelCase	,				__UpperCamelCase  	=      store_two_classics(snake_case			,   snake_case			)
						for i in range(len(snake_case			)			):
												full_adder(snake_case			,   snake_case			,   len(snake_case			) + i			,   len(snake_case			) + len(snake_case			) + i			,   len(snake_case			) + len(snake_case			) + i + 1			)
												circuit.barrier()  # Optional, just for aesthetics

						# Measure the resultant qBits
						for i in range(len(snake_case			) + 1			):
												circuit.measure([(len(snake_case			) * 2) + i]			,   [i]			)

						__UpperCamelCase  	=      qiskit.execute(snake_case			,   snake_case			,   shots=1			).result()

						# The result is in binary. Convert it back to int
						return int(list(res.get_counts()			)[0]			,   2			)


if __name__ == "__main__":
				import doctest

				doctest.testmod()











def  __UpperCamelCase   (     a)			->str:
					if len(a) == 0 or not all(len(a) == 2 for pair in coordinates):
										raise ValueError("The program cannot work out a fitting polynomial.")

					if len({tuple(a) for pair in coordinates}) != len(a):
										raise ValueError("The program cannot work out a fitting polynomial.")

					lowerCamelCase__      =							{x for x, _ in coordinates}
					if len(a) == 1:
										return f"x={coordinates[0][0]}"

					if len(a) != len(a):
										raise ValueError("The program cannot work out a fitting polynomial.")

					lowerCamelCase__      =							len(a)

					lowerCamelCase__      =							0
					lowerCamelCase__      =							[]
					# put the x and x to the power values in a matrix
					while count_of_line < x:
										lowerCamelCase__      =							0
										lowerCamelCase__      =							coordinates[count_of_line][0]
										lowerCamelCase__      =							[]
										while count_in_line < x:
															count_line.append(a ** (x - (count_in_line + 1)))
															count_in_line += 1
										matrix.append(a)
										count_of_line += 1

					lowerCamelCase__      =							0
					# put the y values into a vector
					lowerCamelCase__      =							[]
					while count_of_line < x:
										vector.append(coordinates[count_of_line][1])
										count_of_line += 1

					lowerCamelCase__      =							0

					while count < x:
										lowerCamelCase__      =							0
										while zahlen < x:
															if count == zahlen:
																				zahlen += 1
															if zahlen == x:
																				break
															lowerCamelCase__      =							matrix[zahlen][count] / matrix[count][count]
															for counting_columns, item in enumerate(matrix[count]):
																				# manipulating all the values in the matrix
																				matrix[zahlen][counting_columns] -= item * bruch
															# manipulating the values in the vector
															vector[zahlen] -= vector[count] * bruch
															zahlen += 1
										count += 1

					lowerCamelCase__      =							0
					# make solutions
					lowerCamelCase__      =							[]
					while count < x:
										solution.append(str(vector[count] / matrix[count][count]))
										count += 1

					lowerCamelCase__      =							0
					lowerCamelCase__      =							"f(x)="

					while count < x:
										lowerCamelCase__      =							solution[count].split("E")
										if len(a) > 1:
															lowerCamelCase__      =							f"{remove_e[0]}*10^{remove_e[1]}"
										solved += f"x^{x - (count + 1)}*{solution[count]}"
										if count + 1 != x:
															solved += "+"
										count += 1

					return solved


if __name__ == "__main__":
						print(points_to_polynomial([]))
						print(points_to_polynomial([[]]))
						print(points_to_polynomial([[1, 0], [2, 0], [3, 0]]))
						print(points_to_polynomial([[1, 1], [2, 1], [3, 1]]))
						print(points_to_polynomial([[1, 3], [2, 3], [3, 3]]))
						print(points_to_polynomial([[1, 1], [2, 2], [3, 3]]))
						print(points_to_polynomial([[1, 1], [2, 4], [3, 9]]))
						print(points_to_polynomial([[1, 3], [2, 6], [3, 1_1]]))
						print(points_to_polynomial([[1, -3], [2, -6], [3, -1_1]]))
						print(points_to_polynomial([[1, 5], [2, 2], [3, 9]]))

