




'''simple docstring'''




import qiskit
from qiskit.providers import Backend

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Tuple       ,						SCREAMING_SNAKE_CASE__			:      int       ):
	'''simple docstring'''





	UpperCAmelCase__							,			UpperCAmelCase__										=    bin(SCREAMING_SNAKE_CASE__       )[2:], bin(SCREAMING_SNAKE_CASE__       )[2:]  # Remove leading '0b'

	# Ensure that both strings are of the same length
	if len(SCREAMING_SNAKE_CASE__       ) > len(SCREAMING_SNAKE_CASE__       ):
		UpperCAmelCase__										=    y.zfill(len(SCREAMING_SNAKE_CASE__       )       )
	else:
		UpperCAmelCase__										=    x.zfill(len(SCREAMING_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(SCREAMING_SNAKE_CASE__       ) * 3) + 1       ,						len(SCREAMING_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(SCREAMING_SNAKE_CASE__       )       ):
		if x[::-1][i] == "1":
			circuit.x(SCREAMING_SNAKE_CASE__       )
	for j in range(len(SCREAMING_SNAKE_CASE__       )       ):
		if y[::-1][j] == "1":
			circuit.x(len(SCREAMING_SNAKE_CASE__       ) + j       )

	return circuit, x, y

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Union[str, Any]       ,						SCREAMING_SNAKE_CASE__			:      Dict       ,						SCREAMING_SNAKE_CASE__			:      Union[str, Any]       ,						SCREAMING_SNAKE_CASE__			:      List[str]       ,						SCREAMING_SNAKE_CASE__			:      Optional[Any]       ,						):
	'''simple docstring'''





	circuit.ccx(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
	circuit.cx(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
	circuit.ccx(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
	circuit.cx(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
	circuit.cx(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      List[str]       ,						SCREAMING_SNAKE_CASE__			:      Union[str, Any]       ,						SCREAMING_SNAKE_CASE__			:      Optional[Any] = qiskit.Aer.get_backend("""aer_simulator"""       )       ,						):
	'''simple docstring'''





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

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

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

	UpperCAmelCase__										=    qiskit.execute(SCREAMING_SNAKE_CASE__       ,						SCREAMING_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()






'''simple docstring'''




from collections import namedtuple

UpperCAmelCase_       				=      namedtuple('from_to', 'from_ to')

UpperCAmelCase_       				=      {
    'millimeter': 'mm',
    'centimeter': 'cm',
    'meter': 'm',
    'kilometer': 'km',
    'inch': 'in',
    'inche': 'in',  # Trailing 's' has been stripped off
    'feet': 'ft',
    'foot': 'ft',
    'yard': 'yd',
    'mile': 'mi',
}

UpperCAmelCase_       				=      {
    'mm': from_to(0.001, 1_0_0_0),
    'cm': from_to(0.01, 1_0_0),
    'm': from_to(1, 1),
    'km': from_to(1_0_0_0, 0.001),
    'in': from_to(0.0254, 39.3701),
    'ft': from_to(0.3048, 3.2_8084),
    'yd': from_to(0.9144, 1.0_9361),
    'mi': from_to(1609.34, 0.0_0062_1371),
}

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      float       ,						SCREAMING_SNAKE_CASE__			:      str       ,						SCREAMING_SNAKE_CASE__			:      str       ):
 '''simple docstring'''





 UpperCAmelCase__										=    from_type.lower().rstrip("""s"""       )
 UpperCAmelCase__										=    TYPE_CONVERSION.get(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
 UpperCAmelCase__										=    to_type.lower().rstrip("""s"""       )
 UpperCAmelCase__										=    TYPE_CONVERSION.get(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
 if new_from not in METRIC_CONVERSION:
  UpperCAmelCase__										=    (
      F'''Invalid \'from_type\' value: {from_type!r}.\n'''
      F'''Conversion abbreviations are: {', '.join(SCREAMING_SNAKE_CASE__       )}'''
  )
  raise ValueError(SCREAMING_SNAKE_CASE__       )
 if new_to not in METRIC_CONVERSION:
  UpperCAmelCase__										=    (
      F'''Invalid \'to_type\' value: {to_type!r}.\n'''
      F'''Conversion abbreviations are: {', '.join(SCREAMING_SNAKE_CASE__       )}'''
  )
  raise ValueError(SCREAMING_SNAKE_CASE__       )
 return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to


if __name__ == "__main__":
    import doctest

    doctest.testmod()
