# Do the necessary import for our program
#!pip install qiskit-aqua
from qiskit import BasicAer
from qiskit.aqua.algorithms import Grover
from qiskit.aqua.components.oracles import LogicalExpressionOracle
from qiskit.tools.visualization import plot_histogram

log_expr = '((A & B) | (C & D)) & ~(A & D)'
algorithm = Grover(LogicalExpressionOracle(log_expr))

# Run the algorithm on a simulator, printing the most frequently occurring result
backend = BasicAer.get_backend('qasm_simulator')

result = algorithm.run(backend)
print(result['top_measurement'])

plot_histogram(result['measurement'])