



'''simple docstring'''





import math

import qiskit

def 			a_	(				_lowerCAmelCase = 1			,_lowerCAmelCase = 1			,_lowerCAmelCase = 1			) -> qiskit.result.counts.Counts:
  if (
      isinstance(_lowerCAmelCase			,_lowerCAmelCase			)
      or isinstance(_lowerCAmelCase			,_lowerCAmelCase			)
      or isinstance(_lowerCAmelCase			,_lowerCAmelCase			)
  ):
    raise TypeError('inputs must be integers.'			)

  if (input_a < 0) or (input_a < 0) or (carry_in < 0):
    raise ValueError('inputs must be positive.'			)

  if (
      (math.floor(_lowerCAmelCase			) != input_a)
      or (math.floor(_lowerCAmelCase			) != input_a)
      or (math.floor(_lowerCAmelCase			) != carry_in)
  ):
    raise ValueError('inputs must be exact integers.'			)

  if (input_a > 2) or (input_a > 2) or (carry_in > 2):
    raise ValueError('inputs must be less or equal to 2.'			)

  # build registers
  __lowerCamelCase			:			Tuple       			=					qiskit.QuantumRegister(4			,'qr'			)
  __lowerCamelCase			:			Union[str, Any]       			=					qiskit.ClassicalRegister(2			,'cr'			)
  # list the entries
  __lowerCamelCase			:			str       			=					[input_a, input_a, carry_in]

  __lowerCamelCase			:			int       			=					qiskit.QuantumCircuit(_lowerCAmelCase			,_lowerCAmelCase			)

  for i in range(0			,3			):
    if entry[i] == 2:
      quantum_circuit.h(_lowerCAmelCase			)  # for hadamard entries
    elif entry[i] == 1:
      quantum_circuit.x(_lowerCAmelCase			)  # for 1 entries
    elif entry[i] == 0:
      quantum_circuit.i(_lowerCAmelCase			)  # for 0 entries

    # build the circuit
  quantum_circuit.ccx(0			,1			,3			)  # ccx = toffoli gate
  quantum_circuit.cx(0			,1			)
  quantum_circuit.ccx(1			,2			,3			)
  quantum_circuit.cx(1			,2			)
  quantum_circuit.cx(0			,1			)

  quantum_circuit.measure([2, 3]			,_lowerCAmelCase			)  # measure the last two qbits

  __lowerCamelCase			:			Dict       			=					qiskit.Aer.get_backend('aer_simulator'			)
  __lowerCamelCase			:			Optional[int]       			=					qiskit.execute(_lowerCAmelCase			,_lowerCAmelCase			,shots=1000			)

  return job.result().get_counts(_lowerCAmelCase			)


if __name__ == "__main__":
   print(f'''Total sum count for state is: {quantum_full_adder(1, 1, 1)}''')











'''simple docstring'''





def 			a_	(				_lowerCAmelCase			,_lowerCAmelCase			) -> tuple[float, float]:

  # Check if the input is valid
  if not len(_lowerCAmelCase			) == len(_lowerCAmelCase			) == 3:
    raise ValueError('Please enter a valid equation.'			)
  if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0:
    raise ValueError('Both a & b of two equations can\'t be zero.'			)

  # Extract the coefficients
  __lowerCamelCase			,__lowerCamelCase			,__lowerCamelCase			:			Union[str, Any]       			=					equationa
  __lowerCamelCase			,__lowerCamelCase			,__lowerCamelCase			:			Any       			=					equationa

  # Calculate the determinants of the matrices
  __lowerCamelCase			:			Union[str, Any]       			=					aa * ba - aa * ba
  __lowerCamelCase			:			Dict       			=					ca * ba - ca * ba
  __lowerCamelCase			:			List[str]       			=					aa * ca - aa * ca

  # Check if the system of linear equations has a solution (using Cramer's rule)
  if determinant == 0:
    if determinant_x == determinant_y == 0:
      raise ValueError('Infinite solutions. (Consistent system)'			)
    else:
      raise ValueError('No solution. (Inconsistent system)'			)
  else:
    if determinant_x == determinant_y == 0:
      # Trivial solution (Inconsistent system)
      return (0.0, 0.0)
    else:
      __lowerCamelCase			:			Tuple       			=					determinant_x / determinant
      __lowerCamelCase			:			Union[str, Any]       			=					determinant_y / determinant
      # Non-Trivial Solution (Consistent system)
      return (x, y)






