import qiskit
from qiskit import IBMQ
# IBMQ.save_account('<IBMQ_API_TOKEN>')
IBMQ.load_account()
from qiskit import BasicAer
from qiskit.aqua import QuantumInstance
from qiskit.aqua.algorithms import DeutschJozsa
from qiskit.aqua.components.oracles import TruthTableOracle

qiskit.__qiskit_version__

bitstr = '11110000'
oracle = TruthTableOracle(bitstr)

oracle.circuit.draw(output='mpl')

dj = DeutschJozsa(oracle)
backend = BasicAer.get_backend('qasm_simulator')
result = dj.run(QuantumInstance(backend, shots=1024))
print('The truth table {} represents a {} function.'.format(bitstr, result['result']))

bitstr = '1' * 32
oracle = TruthTableOracle(bitstr)
dj = DeutschJozsa(oracle)
result = dj.run(QuantumInstance(backend, shots=1024))
print('The truth table {} represents a {} function.'.format(bitstr, result['result']))

