code: 
  
  
  
  
  '''simple docstring'''
  
  import numpy as np
  import qiskit
  
  
  def 	_UpperCAmelCase				(  _lowerCamelCase						:       str  ,      _lowerCamelCase						:       int		)    ->						qiskit.QuantumCircuit:
    _lowerCAmelCase       :  List[str]   				=					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:
      _lowerCAmelCase       :  Any   				=					np.random.randint(1  ,      2**num_qubits		)
      # Next, format 'b' as a binary string of length 'n', padded with zeros:
      _lowerCAmelCase       :  List[str]   				=					format(_lowerCamelCase  ,      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(_lowerCamelCase		):
        if bit == "1":
          oracle_qc.x(_lowerCamelCase		)
          # Do the controlled-NOT gates for each qubit, using the output qubit
          # as the target:
      for index in range(_lowerCamelCase		):
        oracle_qc.cx(_lowerCamelCase  ,      _lowerCamelCase		)
      # Next, place the final X-gates
      for index, bit in enumerate(_lowerCamelCase		):
        if bit == "1":
          oracle_qc.x(_lowerCamelCase		)
  
      # 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)
      _lowerCAmelCase       :  Tuple   				=					np.random.randint(2		)
      if output == 1:
        oracle_qc.x(_lowerCamelCase		)
  
    _lowerCAmelCase       :  Optional[Any]   				=					oracle_qc.to_gate()
    _lowerCAmelCase       :  Any   				=					"""Oracle"""  # To show when we display the circuit
    return oracle_gate
  
  
  def 	_UpperCAmelCase				(  _lowerCamelCase						:       qiskit.QuantumCircuit  ,      _lowerCamelCase						:       int		)    ->						qiskit.QuantumCircuit:
    _lowerCAmelCase       :  Optional[Any]   				=					qiskit.QuantumCircuit(num_qubits + 1  ,      _lowerCamelCase		)
    # Set up the output qubit:
    dj_circuit.x(_lowerCamelCase		)
    dj_circuit.h(_lowerCamelCase		)
    # And set up the input register:
    for qubit in range(_lowerCamelCase		):
      dj_circuit.h(_lowerCamelCase		)
    # Let's append the oracle gate to our circuit:
    dj_circuit.append(_lowerCamelCase  ,      range(num_qubits + 1		)		)
    # Finally, perform the H-gates again and measure:
    for qubit in range(_lowerCamelCase		):
      dj_circuit.h(_lowerCamelCase		)
  
    for i in range(_lowerCamelCase		):
      dj_circuit.measure(_lowerCamelCase  ,      _lowerCamelCase		)
  
    return dj_circuit
  
  
  def 	_UpperCAmelCase				(  _lowerCamelCase						:       str  ,      _lowerCamelCase						:       int		)    ->						qiskit.result.counts.Counts:
    _lowerCAmelCase       :  int   				=					qiskit.Aer.get_backend("""aer_simulator"""		)
  
    _lowerCAmelCase       :  Tuple   				=					dj_oracle(_lowerCamelCase  ,      _lowerCamelCase		)
    _lowerCAmelCase       :  str   				=					dj_algorithm(_lowerCamelCase  ,      _lowerCamelCase		)
  
    # Execute the circuit on the simulator
    _lowerCAmelCase       :  Dict   				=					qiskit.execute(_lowerCamelCase  ,      _lowerCamelCase  ,      shots=10_00		)
  
    # Return the histogram data of the results of the experiment.
    return job.result().get_counts(_lowerCamelCase		)
  
  
  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: 
  '''simple docstring'''
  
  import os
  
  
  def 	_UpperCAmelCase				(  )    ->						int:
    _lowerCAmelCase       :  Optional[int]   				=					os.path.dirname(os.path.realpath(_lowerCamelCase		)		)
    _lowerCAmelCase       :  Optional[Any]   				=					os.path.join(_lowerCamelCase  ,      """triangle.txt"""		)
  
    with open(_lowerCamelCase		) as in_file:
      _lowerCAmelCase       :  List[Any]   				=					[[int(_lowerCamelCase		) for i in line.split()] for line in in_file]
  
    while len(_lowerCamelCase		) != 1:
      _lowerCAmelCase       :  Any   				=					triangle.pop()
      _lowerCAmelCase       :  List[str]   				=					triangle[-1]
      for j in range(len(_lowerCamelCase		) - 1		):
        curr_row[j] += max(last_row[j]  ,      last_row[j + 1]		)
    return triangle[0][0]
  
  
  if __name__ == "__main__":
       print(solution())
  
  
  