code: 
  
  
  import numpy as np
  import qiskit
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->qiskit.QuantumCircuit:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   int					   =		qiskit.QuantumCircuit(num_qubits + 1     )
  
        # First, let's deal with the case in which oracle is balanced
        if case == "balanced":
              # First generate a random number that tells us which CNOTs to
              # wrap in X-gates:
              lowercase			:   Tuple					   =		np.random.randint(1,    2**num_qubits     )
              # Next, format 'b' as a binary string of length 'n', padded with zeros:
              lowercase			:   List[Any]					   =		format(_UpperCamelCase,    f"""0{num_qubits}b"""     )
              # Next, we place the first X-gates. Each digit in our binary string
              # corresponds to a qubit, if the digit is 0, we do nothing, if it's 1
              # we apply an X-gate to that qubit:
              for index, bit in enumerate(_UpperCamelCase     ):
                    if bit == "1":
                          oracle_qc.x(_UpperCamelCase     )
          # Do the controlled-NOT gates for each qubit, using the output qubit
          # as the target:
              for index in range(_UpperCamelCase     ):
                    oracle_qc.cx(_UpperCamelCase,    _UpperCamelCase     )
              # Next, place the final X-gates
              for index, bit in enumerate(_UpperCamelCase     ):
                    if bit == "1":
                          oracle_qc.x(_UpperCamelCase     )
  
      # Case in which oracle is constant
        if case == "constant":
              # First decide what the fixed output of the oracle will be
              # (either always 0 or always 1)
              lowercase			:   Tuple					   =		np.random.randint(2     )
              if output == 1:
                    oracle_qc.x(_UpperCamelCase     )
  
        lowercase			:   Any					   =		oracle_qc.to_gate()
        lowercase			:   Optional[Any]					   =		'''Oracle'''  # To show when we display the circuit
        return oracle_gate
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->qiskit.QuantumCircuit:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   List[str]					   =		qiskit.QuantumCircuit(num_qubits + 1,    _UpperCamelCase     )
        # Set up the output qubit:
        dj_circuit.x(_UpperCamelCase     )
        dj_circuit.h(_UpperCamelCase     )
        # And set up the input register:
        for qubit in range(_UpperCamelCase     ):
              dj_circuit.h(_UpperCamelCase     )
        # Let's append the oracle gate to our circuit:
        dj_circuit.append(_UpperCamelCase,    range(num_qubits + 1     )     )
        # Finally, perform the H-gates again and measure:
        for qubit in range(_UpperCamelCase     ):
              dj_circuit.h(_UpperCamelCase     )
  
        for i in range(_UpperCamelCase     ):
              dj_circuit.measure(_UpperCamelCase,    _UpperCamelCase     )
  
        return dj_circuit
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->qiskit.result.counts.Counts:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   str					   =		qiskit.Aer.get_backend('''aer_simulator'''     )
  
        lowercase			:   Any					   =		dj_oracle(_UpperCamelCase,    _UpperCamelCase     )
        lowercase			:   List[str]					   =		dj_algorithm(_UpperCamelCase,    _UpperCamelCase     )
  
        # Execute the circuit on the simulator
        lowercase			:   Optional[int]					   =		qiskit.execute(_UpperCamelCase,    _UpperCamelCase,    shots=1000     )
  
        # Return the histogram data of the results of the experiment.
        return job.result().get_counts(_UpperCamelCase     )
  
  
  if __name__ == "__main__":
    print(F'''Deutsch Jozsa - Constant Oracle: {deutsch_jozsa("constant", 3)}''')
    print(F'''Deutsch Jozsa - Balanced Oracle: {deutsch_jozsa("balanced", 3)}''')
  
  
style_context: 
  
  
  __a   				=      [
      [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
      [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
      [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
  ]
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->bool:
  
  
  
  
  
  
  
        """simple docstring"""
  
        return 0 <= row < rows and 0 <= col < cols
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->int:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Optional[int]					   =		len(_UpperCamelCase     )
        lowercase			:   str					   =		len(mat[0]     )
        if is_safe(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     ) and (row, col) not in seen and mat[row][col] == 1:
              seen.add((row, col)     )
              return (
                  1
                  + depth_first_search(row + 1,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(row - 1,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(_UpperCamelCase,    col + 1,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(_UpperCamelCase,    col - 1,    _UpperCamelCase,    _UpperCamelCase     )
              )
        else:
              return 0
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase     )    ->int:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   set					   =		set()
  
        lowercase			:   Tuple					   =		0
        for row, line in enumerate(_UpperCamelCase     ):
              for col, item in enumerate(_UpperCamelCase     ):
                    if item == 1 and (row, col) not in seen:
                          # Maximizing the area
                          lowercase			:   Tuple					   =		max(_UpperCamelCase,    depth_first_search(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )     )
        return max_area
  
  
  if __name__ == "__main__":
    import doctest
  
    print(find_max_area(matrix))  # Output -> 6
    doctest.testmod()
  
  