
"""simple docstring"""




from __future__ import annotations

import math




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  if len(_UpperCamelCase						) != 2 or len(a[0]						) != 2 or len(_UpperCamelCase						) != 2 or len(b[0]						) != 2:
    raise Exception('''Matrices are not 2x2'''						)
  _lowercase:			Optional[int]       =     [
      [a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
      [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]],
  ]
  return new_matrix




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  return [
      [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]						)						)]
      for row in range(len(_UpperCamelCase						)						)
  ]




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  return [
      [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]						)						)]
      for row in range(len(_UpperCamelCase						)						)
  ]




def  _lowerCAmelCase		(		_UpperCamelCase						):






  """simple docstring"""



  if len(_UpperCamelCase						) % 2 != 0 or len(a[0]						) % 2 != 0:
    raise Exception('''Odd matrices are not supported!'''						)

  _lowercase:			str       =     len(_UpperCamelCase						)
  _lowercase:			str       =     matrix_length // 2

  _lowercase:			Union[str, Any]       =     [[a[i][j] for j in range(_UpperCamelCase ,				_UpperCamelCase						)] for i in range(_UpperCamelCase						)]
  _lowercase:			List[Any]       =     [
      [a[i][j] for j in range(_UpperCamelCase ,				_UpperCamelCase						)] for i in range(_UpperCamelCase ,				_UpperCamelCase						)
  ]

  _lowercase:			List[Any]       =     [[a[i][j] for j in range(_UpperCamelCase						)] for i in range(_UpperCamelCase						)]
  _lowercase:			Optional[int]       =     [[a[i][j] for j in range(_UpperCamelCase						)] for i in range(_UpperCamelCase ,				_UpperCamelCase						)]

  return top_left, top_right, bot_left, bot_right




def  _lowerCAmelCase		(		_UpperCamelCase						):






  """simple docstring"""



  return len(_UpperCamelCase						), len(matrix[0]						)




def  _lowerCAmelCase		(		_UpperCamelCase						):






  """simple docstring"""



  print('''\n'''.join(str(_UpperCamelCase						) for line in matrix						)						)




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  if matrix_dimensions(_UpperCamelCase						) == (2, 2):
    return default_matrix_multiplication(_UpperCamelCase ,				_UpperCamelCase						)

  _lowercase ,				_lowercase ,				_lowercase ,				_lowercase:			Optional[Any]       =     split_matrix(_UpperCamelCase						)
  _lowercase ,				_lowercase ,				_lowercase ,				_lowercase:			Optional[int]       =     split_matrix(_UpperCamelCase						)

  _lowercase:			Dict       =     actual_strassen(_UpperCamelCase ,				matrix_subtraction(_UpperCamelCase ,				_UpperCamelCase						)						)
  _lowercase:			Optional[Any]       =     actual_strassen(matrix_addition(_UpperCamelCase ,				_UpperCamelCase						) ,				_UpperCamelCase						)
  _lowercase:			Optional[Any]       =     actual_strassen(matrix_addition(_UpperCamelCase ,				_UpperCamelCase						) ,				_UpperCamelCase						)
  _lowercase:			Tuple       =     actual_strassen(_UpperCamelCase ,				matrix_subtraction(_UpperCamelCase ,				_UpperCamelCase						)						)
  _lowercase:			Optional[int]       =     actual_strassen(matrix_addition(_UpperCamelCase ,				_UpperCamelCase						) ,				matrix_addition(_UpperCamelCase ,				_UpperCamelCase						)						)
  _lowercase:			Optional[int]       =     actual_strassen(matrix_subtraction(_UpperCamelCase ,				_UpperCamelCase						) ,				matrix_addition(_UpperCamelCase ,				_UpperCamelCase						)						)
  _lowercase:			int       =     actual_strassen(matrix_subtraction(_UpperCamelCase ,				_UpperCamelCase						) ,				matrix_addition(_UpperCamelCase ,				_UpperCamelCase						)						)

  _lowercase:			Optional[int]       =     matrix_addition(matrix_subtraction(matrix_addition(_UpperCamelCase ,				_UpperCamelCase						) ,				_UpperCamelCase						) ,				_UpperCamelCase						)
  _lowercase:			str       =     matrix_addition(_UpperCamelCase ,				_UpperCamelCase						)
  _lowercase:			int       =     matrix_addition(_UpperCamelCase ,				_UpperCamelCase						)
  _lowercase:			Optional[int]       =     matrix_subtraction(matrix_subtraction(matrix_addition(_UpperCamelCase ,				_UpperCamelCase						) ,				_UpperCamelCase						) ,				_UpperCamelCase						)

  # construct the new matrix from our 4 quadrants
  _lowercase:			List[Any]       =     []
  for i in range(len(_UpperCamelCase						)						):
    new_matrix.append(top_left[i] + top_right[i]						)
  for i in range(len(_UpperCamelCase						)						):
    new_matrix.append(bot_left[i] + bot_right[i]						)
  return new_matrix




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  if matrix_dimensions(_UpperCamelCase						)[1] != matrix_dimensions(_UpperCamelCase						)[0]:
    _lowercase:			Any       =     (
        '''Unable to multiply these matrices, please check the dimensions.\n'''
        f'''Matrix A: {matrixa}\n'''
        f'''Matrix B: {matrixa}'''
    )
    raise Exception(_UpperCamelCase						)
  _lowercase:			List[str]       =     matrix_dimensions(_UpperCamelCase						)
  _lowercase:			Tuple       =     matrix_dimensions(_UpperCamelCase						)

  if dimensiona[0] == dimensiona[1] and dimensiona[0] == dimensiona[1]:
    return [matrixa, matrixa]

  _lowercase:			Tuple       =     max(*_UpperCamelCase ,				*_UpperCamelCase						)
  _lowercase:			str       =     int(math.pow(2 ,				math.ceil(math.loga(_UpperCamelCase						)						)						)						)
  _lowercase:			Optional[Any]       =     matrixa
  _lowercase:			Dict       =     matrixa

  # Adding zeros to the matrices so that the arrays dimensions are the same and also
  # power of 2
  for i in range(0 ,				_UpperCamelCase						):
    if i < dimensiona[0]:
      for _ in range(dimensiona[1] ,				_UpperCamelCase						):
        new_matrixa[i].append(0						)
    else:
      new_matrixa.append([0] * maxim						)
    if i < dimensiona[0]:
      for _ in range(dimensiona[1] ,				_UpperCamelCase						):
        new_matrixa[i].append(0						)
    else:
      new_matrixa.append([0] * maxim						)

  _lowercase:			int       =     actual_strassen(_UpperCamelCase ,				_UpperCamelCase						)

  # Removing the additional zeros
  for i in range(0 ,				_UpperCamelCase						):
    if i < dimensiona[0]:
      for _ in range(dimensiona[1] ,				_UpperCamelCase						):
        final_matrix[i].pop()
    else:
      final_matrix.pop()
  return final_matrix


if __name__ == "__main__":
  A__   :					str							=   [
      [2, 3, 4, 5],
      [6, 4, 3, 1],
      [2, 3, 6, 7],
      [3, 1, 2, 4],
      [2, 3, 4, 5],
      [6, 4, 3, 1],
      [2, 3, 6, 7],
      [3, 1, 2, 4],
      [2, 3, 4, 5],
      [6, 2, 3, 1],
  ]
  A__   :					List[Any]							=   [[0, 2, 1, 1], [1_6, 2, 3, 3], [2, 2, 7, 7], [1_3, 1_1, 2_2, 4]]
  print(strassen(matrixa, matrixa))


"""simple docstring"""




import qiskit




def  _lowerCAmelCase		(		_UpperCamelCase ,				_UpperCamelCase						):






  """simple docstring"""



  _lowercase:			Dict       =     qiskit.Aer.get_backend('''aer_simulator'''						)

  # Create a Quantum Circuit acting on the q register
  _lowercase:			str       =     qiskit.QuantumCircuit(_UpperCamelCase ,				_UpperCamelCase						)

  # Apply X (NOT) Gate to Qubits 0 & 1
  circuit.x(0						)
  circuit.x(1						)

  # Map the quantum measurement to the classical bits
  circuit.measure([0, 1] ,				[0, 1]						)

  # Execute the circuit on the qasm simulator
  _lowercase:			Tuple       =     qiskit.execute(_UpperCamelCase ,				_UpperCamelCase ,				shots=1_000						)

  # Return the histogram data of the results of the experiment.
  return job.result().get_counts(_UpperCamelCase						)


if __name__ == "__main__":
  A__   :					Optional[int]							=   single_qubit_measure(2, 2)
  print(f"""Total count for various states are: {counts}""")
